commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fumo, Vince" <>
Subject RE: DBCP and the ConnectionPoolDataSource Interface
Date Mon, 23 Feb 2004 17:22:56 GMT
Thanks Dirk, seems I was looking in DBCP 1.0, 1.1 added a bunch of stuff.
Thanks again

-----Original Message-----
From: Dirk Verbeeck []
Sent: Saturday, February 21, 2004 8:11 AM
To: Jakarta Commons Users List
Subject: Re: DBCP and the ConnectionPoolDataSource Interface

There are 2 almost separate connection pool implementations in the 
DBCP distribution.

The first one is located in org.apache.commons.dbcp.*
Starting from DriverConnectionFactory it builds a PoolingDataSource 
called BasicDataSource (the default tomcat datasource).
More info can be found here:

It provides all pooling features for the DataSource.getConnection() 
method. (see configuration page for details)

The second pool implementation around the interface 
javax.sql.ConnectionPoolDataSource is located in:
It is mostly used for its "per user" connection pools.

<Resource auth="Container" name="jdbc/peruser" 
type="org.apache.commons.dbcp.datasources.PerUserPoolDataSource" />
<ResourceParams name="jdbc/peruser">

The dataSourceName refers to a datasource implementing the 
javax.sql.ConnectionPoolDataSource interface.
You can use a database specific implementation or the generic DBCP one:
<Resource auth="Container" name="jdbc/peruserCPDS" 
type="org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS" />
<ResourceParams name="jdbc/peruserCPDS">

If you need a pooled getConnection() methods use BasicDataSource 
otherwise use PerUserPoolDataSource (with DriverAdapterCPDS or a 
database specific ConnectionPoolDataSource)

One last remark, if you going to use the MySQL driver for the 
ConnectionPoolDataSource be aware of the following issue:


Fumo, Vince wrote:

> I have three different databases I need to manage and I want to use
> connection pooling datasources registered in JNDI as their commonality in
> application. From what I can gather, if the JDBC driver from the db vendor
> has a DataSource implementation that implements ConnectionPoolDataSource,
> can easily register it in JNDI. It's also my understanding that the
> management of the pool itself is not the responsibility of the individual
> JDBC driver. I'm hoping that DBCP can handle my management. 
> What I'd like to implement is a simple method  that will take a
> ConnectionPoolDataSource object, wrap it in pool management and return a
> PoolingDataSource object that I can then register in JNDI. 
> I've looked at the Dialog in the javadoc and I understand how to create a
> pool given a connection string (using the DriverConnectionFactory) but I'm
> not sure how to replace this ConnectionFactory with the
> ConnectionPoolDataSource object. I'm not even sure if this is what I
> be doing.
> I'm sorry if this seems a simple question, but I've looked everywhere and
> can't seem to find anything that references a connection between
> ConnectionPoolDataSource and DBCP (other than the reference in the javadoc
> for DriverAdapterCPDS.
> Thanks for your help.

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

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

View raw message