This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "resultset" Watch "resultset" New topic


jesse harris
Ranch Hand

Joined: Oct 02, 2000
Posts: 62
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
Shaunak Desai

Joined: Jun 14, 2001
Posts: 7

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

Joined: Oct 31, 2000
Posts: 527
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.

SCJP 1.5, SCEA, ICED (287,484,486)
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
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.

Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
I agree. Here's the link:
subject: resultset
It's not a secret anymore!