You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/02/28 22:58:39 UTC

cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/cpdsadapter PooledConnectionImpl.java

dirkv       2004/02/28 13:58:39

  Modified:    dbcp/src/java/org/apache/commons/dbcp/cpdsadapter
                        PooledConnectionImpl.java
  Log:
  Bugzilla Bug 24136: ClassCastException in DriverAdapterCPDS when setPoolPreparedStatements(true)
  - make a DelegatingConnection in PooledConnectionImpl to avoid ClassCastException
  
  Revision  Changes    Path
  1.15      +14 -3     jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java
  
  Index: PooledConnectionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PooledConnectionImpl.java	28 Feb 2004 12:18:17 -0000	1.14
  +++ PooledConnectionImpl.java	28 Feb 2004 21:58:38 -0000	1.15
  @@ -26,6 +26,7 @@
   import javax.sql.ConnectionEventListener;
   import javax.sql.PooledConnection;
   
  +import org.apache.commons.dbcp.DelegatingConnection;
   import org.apache.commons.dbcp.DelegatingPreparedStatement;
   import org.apache.commons.dbcp.SQLNestedException;
   import org.apache.commons.pool.KeyedObjectPool;
  @@ -47,6 +48,11 @@
        * The JDBC database connection that represents the physical db connection.
        */
       private Connection connection = null;
  +    
  +    /**
  +     * A DelegatingConnection used to create a PoolablePreparedStatementStub
  +     */
  +    private DelegatingConnection delegatingConnection = null;
   
       /**
        * The JDBC database logical connection.
  @@ -72,6 +78,11 @@
        */
       PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
           this.connection = connection;
  +        if (connection instanceof DelegatingConnection) {
  +            this.delegatingConnection = (DelegatingConnection) connection;
  +        } else {
  +            this.delegatingConnection = new DelegatingConnection(connection);   
  +        }
           eventListeners = new Vector();
           isClosed = false;
           if (pool != null) {
  @@ -265,13 +276,13 @@
                       && null == key._resultSetConcurrency) {
                   return new PoolablePreparedStatementStub(
                           connection.prepareStatement(key._sql),
  -                        key, pstmtPool, connection);
  +                        key, pstmtPool, delegatingConnection);
               } else {
                   return new PoolablePreparedStatementStub(
                           connection.prepareStatement(key._sql,
                           key._resultSetType.intValue(),
                           key._resultSetConcurrency.intValue()),
  -                        key, pstmtPool, connection);
  +                        key, pstmtPool, delegatingConnection);
               }
           }
       }
  
  
  

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