commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Jakarta-commons Wiki] Update of "DBCP" by WernerFragner
Date Thu, 20 Apr 2006 17:49:12 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.

The following page has been changed by WernerFragner:

  Q: <nowiki>Does the current 1.1 release support the poolable/caching of PreparedStatements.
I noted that the PoolableConnectionFactory can take a KeyedObjectPoolFactory as a statement
pool factory. But there is not concrete implementation for the KeyedPoolableObjectFactory
which is required when creating a GenericKeyedObjectPoolFactory. If I pass in a null as shown
in the examples, does it cache prepared statements or should I do that in local objects?</nowiki>
- A: ??
+ A: 
+ Yes, prepared statements are being cached. Here is a an example how to use the statement
+ {{{
+ ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
+     url, username, password);
+ GenericObjectPool connectionPool = new GenericObjectPool();
+ // null can used as parameter because this parameter is set in 
+ // PoolableConnectionFactory when creating a new PoolableConnection
+ KeyedObjectPoolFactory statementPool = new GenericKeyedObjectPoolFactory(null);
+ final boolean defaultReadOnly = false;
+ final boolean defaultAutoCommit = false;
+ final String validationQuery = null;
+ new PoolableConnectionFactory(connectionFactory, connectionPool, statementPool,
+       validationQuery, defaultReadOnly, defaultAutoCommit);
+ }}}
  Q: Where do I get a concrete example of PerUserPoolDataSource? How do we use it in a situation
where multiple pools are required for different modules of a project and their properties
differ on the database transactional load?

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

View raw message