I noticed that an original connection and one gotten from statement are not equal.
If you're using Commons pooling,
the original one is a wrapped connection. The close() method is overridden to return the connection to the pool, in stead of closing the database connection.
When you're using the connection from the statement, it depends on the
jdbc implementation. You might get the non-wrapped connection.
Closing it would not return the connection to the pool, and close the actual database connection.
You could
test the scenario by creating a pool with one connection,
- Get connection from the pool,
- create a statement,
- get the connection from the statement
- close that connection.
- Get a connection from the pool.
If the last step fails, you have a leak.
Regards, Jan