• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Releasing resources question

 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I used to follow the get-use-close pattern when dealing with Connection, PreparedStatement and ResultSet objects . In a very simple pseudo code, I used to write code like this:



So far, so good... recently I was told by a colleague that closing rs and ps in that scenario isn't necessary to free up resources, because closing connections is enough to let underlying DBMS to free allocated resources.

I'm not really convinced: it may be OK if connection is obtained with a DriverManager.getConnection() statement, but what about a connection leased by a connection pool ?
Can you help me to clarify this scenario ?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic