From my experience DBCP works extremely well as a connection pool, but the API can use some cleanup. My favorite example is PoolableConnectionFactory [1]. So in Cayenne we have code like this:

ObjectPool connectionPool = new GenericObjectPool(null, poolConfig);
new PoolableConnectionFactory(
                factory,
                connectionPool,
                statementPool,
                validationQuery,
                defaultReadOnly ? Boolean.TRUE : Boolean.FALSE,
                defaultAutoCommit,
                defaultTransactionIsolation,
                defaultCatalog,
                null);
return connectionPool;

PoolableConnectionFactory attaches itself to the connection pool inside constructor. Looks weird - an object is created but not assigned to anything. Every time I stumble upon this code, I have to doublecheck that nothing insane is going on. 9-arg constructor is also not good.

Would be cool if new volunteers from Geronimo could refactor things a bit ;-)

Andrus

[1] http://svn.apache.org/repos/asf/jakarta/commons/proper/dbcp/trunk/ src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java



On Jul 12, 2007, at 3:07 AM, Jeff Genender wrote:

Great idea!  +1.

Jeff

Dain Sundstrom wrote:
In the OPENEJB-606, I've added a patch that converts the default data
sources in OpenEJB to use Commons DBCP instead of the OpenEJB
JdbcManagedConnection and SharedLocalConnectionManager. With this patch
applied we can use the configuration properties
http://jakarta.apache.org/commons/dbcp/configuration.html that most
Tomcat users will be familiar with.

If we like DBCP, I think we should drop the JCA based JDBC code and
throw our hat in with the commons team.

BTW, this patch is contingent on
https://issues.apache.org/jira/browse/DBCP-230 being applied which may
take a day or so.

-dain


Reply via email to