You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Apache Wiki <wi...@apache.org> on 2006/04/20 19:49:12 UTC

[Jakarta-commons Wiki] Update of "DBCP" by WernerFragner

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:
http://wiki.apache.org/jakarta-commons/DBCP

------------------------------------------------------------------------------
  
  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 pool:
  
+ {{{
+ 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org