Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cascading object close() statements

 
Andrew Sweeney
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Mahesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic