inline

________________________________

From: Phil Steitz [mailto:[EMAIL PROTECTED]
Sent: Tue 6/19/2007 9:49 PM
To: Jakarta Commons Users List
Subject: Re: [DBCP] The PerUserPoolDataSource/SharedPoolDataSource does not 
reuse/pool the db connections



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:

[Seva] Yes, this test verifies that the pool observes the max active and max 
idle config parameters. And it seems that after the connection was active it 
becomes idle, i.e. it is still in the pool.  But this test can not verify for 
sure that the pool is reusing the physical database connections. For example, 
one can easily break the above by closing the underlying physical connection 
directly in the client code. 


<jsp:directive.page
import="org.apache.tomcat.dbcp.dbcp.datasources.SharedPoolDataSource"
/>
...
SharedPoolDataSource ds = (SharedPoolDataSource)
envContext.lookup("jdbc/MyPool");
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: [EMAIL PROTECTED]
Num Active init 0
Num Idle init 0
Connection 1: [EMAIL PROTECTED]
Num Active one open 1
Num Idle one open 0
Connection 2: [EMAIL PROTECTED]
Num Active two open 2
Num Idle two open 0
Num Active 2 closed 1
Num Idle 2 closed 1
Connection 3: [EMAIL PROTECTED]
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.

[Seva] Yes, I've realized the same today and was going to switch to CPDS 
adapter tomorrow but after I got your previous email things were clarified and 
I verified the Oracle driver is working correctly.

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to