Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-26-2008, 03:10 PM
Member
 
Join Date: Mar 2008
Posts: 4
haneeshrawther is on a distinguished road
Can i use a resultset more than once without closing it
Can i use a resultset more than once without closing it
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-02-2008, 08:34 AM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 183
danielstoner is on a distinguished road
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 @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-18-2008, 08:28 AM
Member
 
Join Date: Jan 2008
Posts: 16
sandeeprao.techno is on a distinguished road
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...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-18-2008, 09:02 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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)
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-18-2008, 11:20 AM
Member
 
Join Date: Jun 2008
Posts: 65
masijade is on a distinguished road
Quote:
Originally Posted by sandeeprao.techno View Post
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...
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-26-2008, 04:16 AM
Eku Eku is online now
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 161
Eku is on a distinguished road
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 ^_^
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.

Last edited by Eku : 06-26-2008 at 04:19 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JFrame (closing under a condition) Java Tip Java Tips 0 03-12-2008 12:17 PM
ResultSet to XML Java Tip Java Tips 0 02-14-2008 10:50 AM
ResultSet example Java Tip Java Tips 0 01-20-2008 09:59 AM
Closing packages uncopywritable New To Java 0 08-14-2007 12:47 AM


All times are GMT +3. The time now is 03:35 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org