wood burning stoves 2.0*
The moose likes JDBC and the fly likes Does ResultSet close when connection closes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Does ResultSet close when connection closes?" Watch "Does ResultSet close when connection closes?" New topic
Author

Does ResultSet close when connection closes?

Jonny Butamer
Greenhorn

Joined: Oct 27, 2004
Posts: 15
Hi,

I'am wondering if anybody knows if the connection closes that was used to retrieve a ResultSet, does the ResultSet also close. Can you continue to use a ResultSet after the connection that retrieved the ResultSet closes?

Thanks for any answers
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The two are different.

I like to close InitialContext, ResultSet, Statement and Connection (in that order).


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
I think you can't use the ResultSet once the Connection that is used to create the ResultSet is closed.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
FYI Plz.

Catchd ResultSet


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
hatim osman
Ranch Hand

Joined: Jun 10, 2005
Posts: 105
hi there...
the ResultSet implementation is very tied with the Connection object that created it. The ResultSet object exsits as long as the Connection Object does. Oneway around this is to make use of a RowSet Object. The RowSet class is an extension of the Statement class; thus it inherits all the capabilities provided in its super class. A RowSet Object caches its ResultSet and also the necessary information to re-establish the connection again. This means that they are serializable!.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The ResultSet object exsits as long as the Connection Object does.

The Connection API documentation does not support this statement. It is possible that some JDBC driver providers may implement this facility, but a developer cannot write portable code on the basis of proprietary features.

The RowSet class is an extension of the Statement class

The RowSet interface is a subinterface of ResultSet.
 
wood burning stoves
 
subject: Does ResultSet close when connection closes?