tags:

views:

164

answers:

1

In the scenario where a connection is got from a database pool(like Commons DBCP, etc) and when the connection is closed using connection.close(), how is the connection returned to the pool?

Is there come callback method in connection object which is called on connection.close() which returns the connection back to the pool from which it originated?

+6  A: 

Usually the connection object you receive is a decorator of the original one and calling close simply returns it to the pool. It does not close it.

Robert Munteanu
yes, that was the question and the answer is correct. The pool returns a connection that encapsulates the real one and calling close() on it simply returns the object to the pool. The underlying connection is closed by other means (pool management)
cadrian