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 Cascading object close() statements 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 "Cascading object close() statements" Watch "Cascading object close() statements" New topic

Cascading object close() statements

Andrew Sweeney

Joined: Jan 11, 2002
Posts: 26
HEllo all,
I'm interested in knowing the order in which JDBC objects are cascaded when closed. My understanding is that when a Connection object is closed, the underlying Statement objects and ResultSet objects are also closed. Is this always the case? Thanks!
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
When we close a Statement object, the associated ResultSet object is closed automatically. The Connection object will have to be closed explicitly. Here's an extract from the Java API :
"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."
Hope it helps.

Have you checked out Aspose?
subject: Cascading object close() statements
It's not a secret anymore!