wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes Closing connection 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 "Closing connection" Watch "Closing connection" New topic

Closing connection

PN Kumar
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
When closing the connection with the back-end server, wont the result set and statement object be closed automatically? Or is explicit closing of statement and resultSet a preferred way of doing it?
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Explicit closing of the ResultSet and Statement is the preferred way to go. This let's the database server free its resources.
If you close the Connection w/out closing the ResultSet, your Java resources are freed, but the database may still consider the ResultSet (cursor) to be open. I've seen this lead to a "Maximum number of cursors exceeded" error.
I agree. Here's the link: http://aspose.com/file-tools
subject: Closing connection
It's not a secret anymore!