The DriverManager already keeps a copy of PoolingDriver so you don't need to make it static.
In your DatabaseUtil.setupPool you can do:
Class.forName("org.apache.commons.dbcp.PoolingDriver");
PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
driver.registerPool(poolName, connectionPool);
In someclass you can do:
Class.forName("org.apache.commons.dbcp.PoolingDriver");
PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
ObjectPool pool = driver.getPool(poolName);
A pool can then report the statistics you need: connection has been used = pool.getNumActive(); remaining connections = pool.getNumIdle();
Regards Dirk
Keith Chiu wrote:
<removed example>Hi, I am using common dbcp 1.0 I followed the ManualPoolingDriverExample.java to implement the connection pooling in the project.
Source code: Basically there are 2 classes
1) DatabaseUtil.java (for setting up connection pool by passing the poolName. The project that I did have multiple modules, each module has its own pool, that's why I using the poolName as an identifier) 2) SomeClass.java (for call the databaseUtil and using the connection)
Here are the Question
1) Is there any way I can gather the information for the exiting connections in the the pool (e.g. connection has been used, remaining connections....)? I would like to get it from the SomeClass. 2) Design issue: Did I implement right. In the databaseUtil, do I need to make Pooldriver as static so that every modules can share the same driver??
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
