You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Keith Veleba <ke...@veleba.net> on 2003/05/28 18:49:52 UTC
DBCP sample usage questions
Hello,
I'm currently in the process of retrofitting an application that
contains some database connection pooling. Unfortunately, scalability
issues with the current custom pooling implementation have cropped up,
forcing a rewrite of those pools. In my search, I discovered the DBCP
and decided to use it to implement more robust pools in our application.
However, I have a question that I'm hoping someone can answer.
1) My application calls for a number of pools to be created to
different databases. I would like to know how best to use the objects
provided. Currently, our pooling is implemented using the Singleton
design pattern; I would like to create a version of that class which
uses the DBCP for pooling, and not our homegrown pooling code.
In the manual pooling example shown, the pool consists of the following
objects:
ObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(connectURI,null);
PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory,connectionPool,null,null,fal
se,true);
PoolingDriver driver = new PoolingDriver();
driver.registerPool("example",connectionPool);
I would assume from this example that for any number of pools, I would
need instances of the following:
1 ObjectPool, ConnectionFactory, and PoolableConnectionFactory for each
database connection pool
1 PoolingDriver for all connection pools.
Is this essentially correct?
Thanks,
Keith Veleba
<ke...@veleba.net>
[DBCP] sample usage questions
Posted by Keith Veleba <ke...@veleba.net>.
Hello,
I'm currently in the process of retrofitting an application that
contains some database connection pooling. Unfortunately, scalability
issues with the current custom pooling implementation have cropped up,
forcing a rewrite of those pools. In my search, I discovered the DBCP
and decided to use it to implement more robust pools in our application.
However, I have a question that I'm hoping someone can answer.
1) My application calls for a number of pools to be created to
different databases. I would like to know how best to use the objects
provided. Currently, our pooling is implemented using the Singleton
design pattern; I would like to create a version of that class which
uses the DBCP for pooling, and not our homegrown pooling code.
In the manual pooling example shown, the pool consists of the following
objects:
ObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(connectURI,null);
PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory,connectionPool,null,null,fal
se,true);
PoolingDriver driver = new PoolingDriver();
driver.registerPool("example",connectionPool);
I would assume from this example that for any number of pools, I would
need instances of the following:
1 ObjectPool, ConnectionFactory, and PoolableConnectionFactory for each
database connection pool
1 PoolingDriver for all connection pools.
Is this essentially correct?
Thanks,
Keith Veleba
<ke...@veleba.net>