commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [dbcp] PoolingDataSource setup problem
Date Sat, 13 Aug 2011 22:36:38 GMT
On 8/11/11 1:36 AM, Andrea Sodomaco wrote:
>  Hi,
>
> I tried to follow this example
> http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java?view=markup
>
>
> but at lines 148/149
> 148 PoolableConnectionFactory poolableConnectionFactory =
> 149         new PoolableConnectionFactory(connectionFactory);
>
> it fails because, according to
> http://commons.apache.org/dbcp/api-1.4/index.html
> <http://commons.apache.org/dbcp/api-1.4/index.html>, all
> constructors need an ObjectPool
> but also all costructors of GenericObjectPool need a
> PoolableObjectFactory!
>
> I "solved" the problem by this work-around
> PoolableConnectionFactory poolableConnectionFactory =
>                   new
> PoolableConnectionFactory(connectionFactory,*new
> GenericObjectPool()*,null,null,false,false);
>
> ObjectPool connectionPool =    new
> GenericObjectPool(poolableConnectionFactory);
> poolableConnectionFactory.setPool(connectionPool);
>
>
> that uses a  "fake"  GenericObjectPool.
> I don't think this is the right solution. What I am missing?

Sorry for the slow response.  The example at the URL above is for
the (still stabilizing) 2.0 version of DBCP.  The funny setup that
you have pointed out is being fixed in 2.0..  What you need to do in
1.x, is to follow the example here:
http://svn.apache.org/viewvc/commons/proper/dbcp/tags/DBCP_1_4/doc/ManualPoolingDataSourceExample.java?revision=910071&view=markup

To work around the circularity, the example creates a
GenericObjectPool with a null factory and then passes the pool to
the PoolableConnectionFactory constructor, which as a side effects
calls the pool's setFactory method to associated it with the pool.

Phil
>
> Thanks in advance.
> Andrea
>
>


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


Mime
View raw message