commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <>
Subject Re: [dbcp]PoolableConnection BUG?
Date Thu, 11 Sep 2003 21:37:59 GMT
OK, this needs to be fixed.

I'll thinking about making PoolGuardConnectionWrapper a subclass of 
and implement the getDelegate() & getInnermostDelegate()

You can then do:

Connection conn = dataSource.getConnection();
Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();

Make a bugzilla issue to keep track of this if you want.


Phillip Qin wrote:

>PoolGuardConnectionWrapper was introduced to fix "connection close twice".
>However it didn't consider some one like me rely on getDelegate to do
>something. I have removed PoolGuardConnectionWrapper from PoolingDataSource
>and rebuilt my own branch of commons-dbcp based on 20030910 nightly build.
>Should I file a bug into bugzilla?
> -----Original Message-----
>From: Phillip Qin [] 
>Sent: September 11, 2003 2:59 PM
>To: 'Jakarta Commons Users List'
>Subject: RE: [dbcp]PoolableConnection BUG?
>I think I figured it out.
>In version 1.7, PoolGuardConnectionWrapper was added to wrap around
>PoolableConnection in PoolingDataSource.
>     public Connection getConnection() throws SQLException {
>         try {
>-            return (Connection)(_pool.borrowObject());
>+            Connection conn = (Connection)(_pool.borrowObject());
>+            if (conn != null) {
>+                conn = new PoolGuardConnectionWrapper(conn);
>+            } 
>+            return conn;
>-: 1.6, +: 1.7
>That's why the connection is not an instanceof PoolableConnection.
>Now my question is,
>I want to pass a SQL Array to Oracle stored procedure. In order to create an
>array descriptor, Oralce's ArrayDescriptor.createDescriptor(sqlArrayType,
>conn) requires conn a java.sql.Connection. It doesn't recognize a connection
>wrapper. In order to get the underlying Connection, I have to use
>getDelegate method. In order to use getDelegate method, I have to get a
>PoolableConnection or PoolGuardConnectionWrapper which has getDelegate
>method. If PoolGuardConnectionWrapper is private, how am I supposed to
>-----Original Message-----
>From: Phillip Qin [] 
>Sent: September 11, 2003 1:32 PM
>Subject: [dbcp]PoolableConnection BUG?
>BasicDataSource getConnection returns java.sql.Connection which is actually
>org.apache.commons.dbcp.PoolableConnection. When I cast this connection to
>PoolableConnection, I got ClassCastException.
>Connection conn = dataSource.getConnection();
>Connection dconn = ((PoolableConnection) conn).getDelegate() ;
>(PoolableConnection) conn throws ClassCastException.
>I didn't get the same exception in release 1.0. This happens on snapshot
>20030910 and 20030911. I also use commons-pool snapshot 20030910. Is it s

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

View raw message