Results 1 to 6 of 6
- 04-26-2008, 02:10 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 6
- Rep Power
- 0
- 05-02-2008, 07:34 AM #2
What do you mean? You can use it until you get all the data out of it. If it has more than one row you use it more than once.
Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 06-18-2008, 07:28 AM #3
Member
- Join Date
- Jan 2008
- Posts
- 24
- Rep Power
- 0
You cannot use the resultset more than once...
Once you have called the next row(), the resultset cannot be called back to the previous row...
- 06-18-2008, 08:02 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, you can do whatever you want before close the result set if you render a single data row. If you have multiple rows, after calling a one you can use the previous one. Basically the new one overwrite the new.(don't confused this with memory)
- 06-18-2008, 10:20 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Yes you can, create a Scrollable ResultSet (see the API docs for the createStatement() method), scroll through it with next(), then call either beforeFirst() and scroll through it with next() again. The only question is why?
If the ResultSet is not too large, why don't you just save the rows to an ArrayList as you go through it the first time, then use that ArrayList for any further actions? That would completely eliminate any network latency on additional reads.
- 06-26-2008, 03:16 AM #6
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
Yes you can. ^_^
Ive done it, Im using 3 Result Set in a for loop. I used them to save connection in the port for multiple batch processing. And it is also possible to return to the previous row or any Row you would like. You Just to set the following
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_READ_ONLY); <-- Scrollable but Read Only
Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_UPDATABLE); <-- Scrollable and editable but requires a single connection
then you can invoke the ff:
rs.beforefirst() or rs.first() to return to the start
rs.previous() to return one row back
rs.afterLast() or rs.last() to go the last part if you want to insert a new Row
rs.absolute(int X) <--to go to a specific Row
But I think i masijade's solution to save it to a arraylist is a better approach if you will only need to get data from the database ^_^Last edited by Eku; 06-26-2008 at 03:19 AM.
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Similar Threads
-
JFrame (closing under a condition)
By Java Tip in forum Java TipReplies: 0Last Post: 03-12-2008, 11:17 AM -
ResultSet to XML
By Java Tip in forum Java TipReplies: 0Last Post: 02-14-2008, 09:50 AM -
ResultSet example
By Java Tip in forum Java TipReplies: 0Last Post: 01-20-2008, 08:59 AM -
Closing packages
By uncopywritable in forum New To JavaReplies: 0Last Post: 08-13-2007, 11:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks