commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <dirk.verbe...@pandora.be>
Subject Re: [DBCP] Help on gathering pool information
Date Sun, 28 Sep 2003 19:54:04 GMT
The ManualPoolingDriverExample.java  is misleading I think.
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:

>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??
>
>  
>
<removed example>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message