You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2008/07/12 03:41:58 UTC

How does DBCP determine to reuse a connection?

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?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details. 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: How does DBCP determine to reuse a connection?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Phil:

I used the patch to compile DBCP under JDK 6 and
then added a bunch of logging to the DBCP code.

I found a bug in the clearWarnings() implementation on
my Conection class (It was accidentally throwing an 
exception - doh!).   Once I fixed that, DBCP is now 
reusing my connections.

Thanks for your help in getting this fixed.

	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.  

> How have you configured DBCP and how are you testing? 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: How does DBCP determine to reuse a connection?

Posted by Phil Steitz <ph...@steitz.com>.
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.
http://commons.apache.org/dbcp/
You might find the sequence diagrams useful
http://commons.apache.org/dbcp/guide/sequencediagrams.html

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? 

Phil
> Thanks,
> 	Neil
>
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details. 
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org