commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <>
Subject Re: [DBCP] The PerUserPoolDataSource/SharedPoolDataSource does not reuse/pool the db connections
Date Wed, 20 Jun 2007 04:49:08 GMT
Two more comments on this.  First, by modifying the jsp to cast the ds
as a SharedPoolDataSource, you can call the getNumActive and
getNumIdle methods to verify that the pool is working correctly:
SharedPoolDataSource ds = (SharedPoolDataSource)
System.out.println("DataSource: " + ds);
System.out.println("Num Active init " + ds.getNumActive());
System.out.println("Num Idle init " + ds.getNumIdle());

Connection conn1 = ds.getConnection("phil", "zft0done");
System.out.println("Connection 1: " + conn1);
System.out.println("Num Active one open " + ds.getNumActive());
System.out.println("Num Idle one open " + ds.getNumIdle());

For PerUserPoolDataSource, you need to supply uid/pwd to the getNumXxx
methods per the javadoc to get correct counts.

For SharedPoolDataSource, I get the expected output with the setup I
described above:
DataSource: org.apache.tomcat.dbcp.dbcp.datasources.SharedPoolDataSource@1ad98ef
Num Active init 0
Num Idle init 0
Connection 1: oracle.jdbc.driver.LogicalConnection@16d2702
Num Active one open 1
Num Idle one open 0
Connection 2: oracle.jdbc.driver.LogicalConnection@1556d12
Num Active two open 2
Num Idle two open 0
Num Active 2 closed 1
Num Idle 2 closed 1
Connection 3: oracle.jdbc.driver.LogicalConnection@16be68f
Num Active 3rd open 2
Num Idle 3rd open 0
Num Active 1 closed 1
Num Idle 1 closed 1
Num Active all closed 0
Num Idle all closed 2

Second, if for some reason your version of the Oracle drivers is not
working correctly, you can use a cpds adapter.  See the Wiki example
referenced above or the package javadoc for o.a.c.dbcp.cpsdadapter for
info on how to configure this.


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

View raw message