• Post Reply Bookmark Topic Watch Topic
  • New Topic

Releasing resources question

Claude Moore
Ranch Hand
Posts: 834
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 ?

Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!