wood burning stoves 2.0*
The moose likes JDBC 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
Bookmark "Closing connection" Watch "Closing connection" New topic
Author

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.
 
GeeCON Prague 2014
 
subject: Closing connection