aspose file tools*
The moose likes JDBC and the fly likes closing connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "closing connections" Watch "closing connections" New topic
Author

closing connections

binu sukumar
Greenhorn

Joined: Aug 07, 2001
Posts: 7
When we close a connection (connectionobject.close()),
will the statements and resultsets automatically get closed..?
Or, do we have to close statements and resultsets explicitly..?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, they will all close too, since they depend on the connection. It's advisable to close your statement & resultset separately though.
------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
I also believe there's a way to use disconnected ResultSets such that if the connection is closed the ResultSet can still be used. Am I right?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
The resultse is a pointer to a row(s) that match the criteria. You will need to put your rows in some kind of collection such an ArrayList, if you want to access it when the connection is closed. There could be another way that I am not aware of.
------------------
Bosun
SCJP for the Java� 2 Platform
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Stanley:
I think you are referring to a CachedRowSet?
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Bingo! That's it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: closing connections