You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Andres Galeano <ag...@perfectorder.com> on 2005/05/24 16:32:39 UTC
[dbcp] Stmt Pooling FAQ Update and Example
Hi all,
I'd like to offer an answer to one of your unanswered FAQs:
On: http://wiki.apache.org/jakarta-commons/DBCP
Under: FAQ
There is the following question:
************************************************************
Q: <nowiki>Does the current 1.1 release support the poolable/caching of
PreparedStatements. (etc...)
A: ??
************************************************************
Currently this question is unanswered. I had the same issue, and
through reading the API of commons-DBCP and commons-POOL I was able to
figure out how to use your Prepared Statement pooling.
In face I created JUnit test case(attached) that shows exactly how to do
this.
I think it would be great if you could answer this questions with
something like:
************************************************************
A: The implementation of
org.apache.commons.pool.KeyedPoolableObjectFactory we provide is
org.apache.commons.dbcp.PoolingConnection. You don't see it in the
commons-pool api because it's exists in the commons-dbcp api.
You can created one with code like this:
------------
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(url, user, password);
new PoolingConnection(connectionFactory.createConnection());
------------
Remember to close your PoolingConnection when your done, so that the
underlying java.sql.Connection also get's closed.
Also see this example that Andres Galeano
<an...@perfectorder.com> from Perfect Order has provided...
************************************************************
Any way, Thanks for reading this,
Andy G.
--
Andres Galeano <an...@perfectorder.com>
Perfect Order Software Solutions
Work: 717-506-1112 x350
Cell: 717-919-5524
AIM/ICQ id: andygaleano
Re: [dbcp] Stmt Pooling FAQ Update and Example
Posted by Andres Galeano <ag...@perfectorder.com>.
Hi all,
Sorry for the second email, but I realized I made a mistake with the
first answer...
"GenericKeyedObjectPoolFactory" actually pools prepared statements even
if you provide "null" as the "KeyedPoolableObjectFactory". I discovered
this through testing(attached), it would be nice if someone could add
that to the javadoc.
************************************************************
Q: <nowiki>Does the current 1.1 release support the poolable/caching of
PreparedStatements. (etc...)
A: The implementation of
org.apache.commons.pool.KeyedPoolableObjectFactory we provide is
org.apache.commons.dbcp.PoolingConnection. You don't see it in the
commons-pool api because it's exists in the commons-dbcp api.
Although you don't need to provide a KeyedPoolableObjectFactory at all.
"GenericKeyedObjectPoolFactory" will correctly pool prepared statements
even if you provide "null" as the "KeyedPoolableObjectFactory".
************************************************************
Thanks again for reading this,
Andy G.
On Tue, 2005-05-24 at 10:32, Andres Galeano wrote:
> Hi all,
>
> I'd like to offer an answer to one of your unanswered FAQs:
>
> On: http://wiki.apache.org/jakarta-commons/DBCP
> Under: FAQ
> There is the following question:
>
> ************************************************************
> Q: <nowiki>Does the current 1.1 release support the poolable/caching of
> PreparedStatements. (etc...)
>
> A: ??
> ************************************************************
>
> Currently this question is unanswered. I had the same issue, and
> through reading the API of commons-DBCP and commons-POOL I was able to
> figure out how to use your Prepared Statement pooling.
>
> In face I created JUnit test case(attached) that shows exactly how to do
> this.
>
> I think it would be great if you could answer this questions with
> something like:
>
> ************************************************************
> A: The implementation of
> org.apache.commons.pool.KeyedPoolableObjectFactory we provide is
> org.apache.commons.dbcp.PoolingConnection. You don't see it in the
> commons-pool api because it's exists in the commons-dbcp api.
>
> You can created one with code like this:
> ------------
> ConnectionFactory connectionFactory = new
> DriverManagerConnectionFactory(url, user, password);
> new PoolingConnection(connectionFactory.createConnection());
> ------------
>
> Remember to close your PoolingConnection when your done, so that the
> underlying java.sql.Connection also get's closed.
>
> Also see this example that Andres Galeano
> <an...@perfectorder.com> from Perfect Order has provided...
> ************************************************************
>
> Any way, Thanks for reading this,
> Andy G.
--
Andres Galeano <an...@perfectorder.com>
Perfect Order Software Solutions
Work: 717-506-1112 x350
Cell: 717-919-5524
AIM/ICQ id: andygaleano