File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset" Watch "resultset" New topic
Author

resultset

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
jesse
Shaunak Desai
Greenhorn

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
author
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: resultset