This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Result Sets and Closing Connections
 
It's not a secret anymore!