Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

resultset data stored in database or java

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic