Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resultset data stored in database or java

 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i get a resultset by executing a query is the data stored in java or i database and resultset has only pointer to that records in database.
Thanks
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you execute a query, using any of the statement.executeXXX (executeUpdate, executeQuery or execute) methods, the query is executed on the database and results wrapped and returned in ResultSet object by the driver.
Once you have got a handle to this ResultSet object, you can do whatever you want with the values contained by it. It is not going to affect the database values in any manner.
 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Abhishek Asthana:
When you execute a query, using any of the statement.executeXXX (executeUpdate, executeQuery or execute) methods, the query is executed on the database and results wrapped and returned in ResultSet object by the driver.
Once you have got a handle to this ResultSet object, you can do whatever you want with the values contained by it. It is not going to affect the database values in any manner.

Let i close the connection then i try rs.next() it gives error
resultset closed.If all results are wrapped and in java then why we can't iterate through resultset.
thanks
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think all JDBC result sets are lazy loading, meaning they may not fetch all rows across the wire from the database into your memory until you scroll to a point where they're needed. That may force the database to hold some of your results in memory until you load to the end or close the resultset. I've never heard any concern about that being a problem on the db server.

And once you move past a row the resultset can throw it away, unless you've specified bidirectional scrolling.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic