commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Qin <Phillip....@shareowner.com>
Subject RE: [dbcp]PoolableConnection BUG?
Date Thu, 11 Sep 2003 20:01:35 GMT
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 [mailto:Phillip.Qin@shareowner.com] 
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
getDelegate?

-----Original Message-----
From: Phillip Qin [mailto:Phillip.Qin@shareowner.com] 
Sent: September 11, 2003 1:32 PM
To: commons-user@jakarta.apache.org
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
bug?


Regards,
PQ

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message