commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <>
Subject Re: Pooling prepared statements with dbcp/pool packaegs
Date Sat, 27 Mar 2004 17:04:24 GMT
Hi Derek,

see inline

Scherger, Derek wrote:

> To help me understand the dbcp/pool packages I'm trying to get a unit test
> going that shows that the underlying statements are actually being pooled
> with dbcp but so far it looks like they are not.

Improvements to the documentation/examples are very welcome ;-)

> To enable statement caching PoolableConnectionFactory wants a
> KeyedObjectPoolFactory (which is an interface) in the constructor. Two
> classes implement this interface, GenericKeyedObjectPoolFactor and
> StackKeyedObjectPoolFactory. 
> GenericKeyedObjectPoolFactory wants a KeyedPoolableObjectFactory in its
> constructor, which is another interface with one *abstract* implementation
> BaseKeyedPoolableObjectFactory. Do I need my on concrete implementation of
> this class to ultimately use GenericKeyedObjectPoolFactory? This would seem
> rather strange, or does it just indicate that this aspect of the dbcp/pool
> packages is not yet complete?

Each PoolingConnection needs a KeyedObjectPool to pool its 
PreparedStatements. To create these pools a KeyedObjectPoolFactory is 
used. For example a GenericKeyedObjectPoolFactory to create 

Each of these pools should be able to create prepared statements for 
the PoolingConnection they are associated with. Therefor they use a 
KeyedPoolableObjectFactory to create the PoolablePreparedStatement.

And the class creating the PoolablePreparedStatements is... 

PoolingConnection implements the KeyedPoolableObjectFactory interface 
and therefor indirectly instantiates its own 
PoolablePreparedStatements. KeyedObjectPool.borrowObject() will use 
the PoolingConnection.makeObject() method to create new 
PoolablePreparedStatements if needed.

> StackKeyedObjectPoolFactory also wants a KeyedPoolableObjectFactory in many
> (but not all) of its constructors so I'm blocked from using most of them too
> unless I have my own implementation of KeyedPoolableObjectFactory.
> I'm off to try one of the StackKeyedObjectPoolFactory constructors that
> seems to be available but any help/advice/information on the above would be
> most appreciated.

I hope you find this info usefull :-)


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

View raw message