commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
Subject Re: How does DBCP determine to reuse a connection?
Date Sat, 12 Jul 2008 16:05:47 GMT
Neil Aggarwal wrote:
> Hello:
> I am writing a JDBC driver that encapsulates the
> MySQL driver and adds some custom logging and functionality.
> When I use DBCP with my driver, it is not reusing connections.
> When I use DBCP with the MySQL driver, it is reusing the
> connections.
> I need to figure out is how DBCP determines it is
> going to reuse the connections to ensure my code complies
> with its expectations.
> Is there a document that covers this?
All DBCP documentation is either in the javadoc or on the website.
You might find the sequence diagrams useful

DBCP maintains a pool of objects that wrap physical database connections 
created using a PoolableConnectionFactory.  PoolableConnectionFactory 
uses a DBCP's DriverManagerConnectionFactory or DriverConnectionFactory 
to invoke DriverManger.getConnection or driver.connect, resp. 

If there are idle connections available in the pool, DBCP will try to 
reuse them.  If testOnBorrow is set to true, connections are validated 
before being returned to clients and if validation fails, they are 
destroyed.  There are also configuration options to close abandoned 
connections or connections that have been idle in the pool beyond a 
configurable idle timeout.  These options can also prevent connections 
from being reused.

How have you configured DBCP and how are you testing? 

> Thanks,
> 	Neil
> --
> Neil Aggarwal, (832)245-7314,
> Eliminate junk email and reclaim your inbox.
> Visit for details. 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message