Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Closing connection

 
PN Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic