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 ?