Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resultset

 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is my understanding that the resultset only persists as long as the connection to the db, is there any way to get around that?
or do I need to create my own resulset class without this restriction and dump the data in there. or am I totally lost?
thanks a lot in advance for any help
jesse
 
Shaunak Desai
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes, the resultset will get close when you close the DB connection. There is no way other than to store the data you got from the resultset in some variables defined in your class.In your words , dump the data in your class.
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better use collection classes (Hashatable, Vector etc.) to store result set data in local memory for a faster retrieval. Even if u close connection, u can find out data in local memory using collection classes.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be able to use javax.sql.CachedRowSet from the JDBC 2 Optional Package. But in general it's probably better to encapsulate your results in objects and stuff those into a collection.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic