aspose file tools*
The moose likes JDBC and the fly likes Result Sets and Closing Connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Result Sets and Closing Connections" Watch "Result Sets and Closing Connections" New topic
Author

Result Sets and Closing Connections

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Can you normally retrieve your recordset, close your connection and still get your data from the record set? Just curious. Is this normal for all connections?


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Dale DeMott:
Can you normally retrieve your recordset, close your connection and still get your data from the record set? Just curious. Is this normal for all connections?

negative on that one. Connection.close() calls the close methods on all associated statements which in turn calls the close() method on any resultsets associated with the statement.
The result is a closed resultset when you close it's underlying connection.
To avoid this, save your resultset to an arraylist or other Collection, then close the connection and resultset and use the collection.
Jamie
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Thanks! Great explanation!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Result Sets and Closing Connections
 
Similar Threads
Bad practice with datasource?
statement N connection
Cannot create PoolableConnectionFactory
weblogic server connection pool problem
Dynamic IP address and socket programming.