Clean up connections before releasing them to the cache

Many JDBC programs do not explicitly clean up java.sql.Statement objects. Instead, they rely on the JDBC driver to clean up Statement objects when the connection is closed. This strategy does not work with cached connections; you must explicitly clean up Statement objects before releasing a connection back into the cache. To clean up Statement objects, call Statement.close() and set the Statement reference to null.

WARNING! To prevent memory leaks, you must explicitly clean up a connection’s Statement objects before releasing the connection back into the cache. Do not release the same connection more than once.