jmcnally    01/12/30 09:29:44

  Modified:    proposals/jdbc2pool/org/apache/torque/jdbc2pool/adapter Tag:
                        JDBC2POOL_BRANCH PooledConnectionImpl.java
                        ConnectionImpl.java
  Log:
  set logging category in class instead of asking Torque.
  
  fix npe in PooledConnectionImpl where torqueConnection is null when
  the class is first instantitated.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +11 -5     
jakarta-turbine-torque/proposals/jdbc2pool/org/apache/torque/jdbc2pool/adapter/PooledConnectionImpl.java
  
  Index: PooledConnectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/proposals/jdbc2pool/org/apache/torque/jdbc2pool/adapter/PooledConnectionImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- PooledConnectionImpl.java 15 Aug 2001 17:38:54 -0000      1.1
  +++ PooledConnectionImpl.java 30 Dec 2001 17:29:44 -0000      1.1.2.1
  @@ -70,13 +70,14 @@
   import javax.sql.ConnectionEventListener;
   import javax.sql.PooledConnection;
   import org.apache.torque.Torque;
  +import org.apache.log4j.Category;
   
   /**
    * Implementation of PooledConnection that is returned by
    * PooledConnectionDataSource.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>John D. McNally</a>
  - * @version $Id: PooledConnectionImpl.java,v 1.1 2001/08/15 17:38:54 jmcnally Exp $
  + * @version $Id: PooledConnectionImpl.java,v 1.1.2.1 2001/12/30 17:29:44 jmcnally 
Exp $
    */
   public class PooledConnectionImpl 
       implements PooledConnection
  @@ -97,12 +98,18 @@
       private Vector eventListeners;
   
       /**
  +     * Log4j logging category.
  +     */
  +    private Category category;
  +    
  +    /**
        * Wrap the real connection.
        */
       PooledConnectionImpl(Connection connection)
       {
           this.connection = connection;
           eventListeners = new Vector();
  +        category = Category.getInstance(getClass().getName());
       }
   
       /**
  @@ -131,7 +138,7 @@
           throws SQLException
       {
           // make sure the last connection is marked as closed
  -        if ( !torqueConnection.isClosed() ) 
  +        if ( torqueConnection != null && !torqueConnection.isClosed() ) 
           {
               // should notify pool of error so the pooled connection can
               // be removed !FIXME!
  @@ -162,9 +169,8 @@
           // to a ConnectionPool, it means that it was taken from a pool
           // and not returned.  We log this fact, close the underlying
           // Connection, and return it to the ConnectionPool.
  -        Torque.getCategory().warn( "A PooledConnection was " 
  -                                   + "finalized, without being returned "
  -                                   + "to the ConnectionPool it belonged to" );
  +        category.warn("A PooledConnection was finalized, without being " + 
  +                        "returned to the ConnectionPool it belonged to");
           
           // Closing the Connection ensures that if anyone tries to use it,
           // an error will occur.
  
  
  
  1.1.2.1   +31 -24    
jakarta-turbine-torque/proposals/jdbc2pool/org/apache/torque/jdbc2pool/adapter/ConnectionImpl.java
  
  Index: ConnectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/proposals/jdbc2pool/org/apache/torque/jdbc2pool/adapter/ConnectionImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- ConnectionImpl.java       15 Aug 2001 17:38:54 -0000      1.1
  +++ ConnectionImpl.java       30 Dec 2001 17:29:44 -0000      1.1.2.1
  @@ -69,12 +69,13 @@
   import javax.sql.ConnectionEventListener;
   import javax.sql.PooledConnection;
   import org.apache.torque.Torque;
  +import org.apache.log4j.Category;
   
   /**
    * This class wraps the JDBC <code>Connection</code> class.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>John D. McNally</a>
  - * @version $Id: ConnectionImpl.java,v 1.1 2001/08/15 17:38:54 jmcnally Exp $
  + * @version $Id: ConnectionImpl.java,v 1.1.2.1 2001/12/30 17:29:44 jmcnally Exp $
    */
   public class ConnectionImpl 
       implements Connection
  @@ -95,6 +96,11 @@
        * Marks whether is Connection is still usable.
        */
       boolean isClosed;
  +
  +    /**
  +     * Log4j logging category.
  +     */
  +    private Category category;
       
       /**
        * Creates a <code>TorqueConnection</code>.
  @@ -108,6 +114,7 @@
           this.pooledConnection = pooledConnection;
           this.connection = connection;
           isClosed = false;
  +        category = Category.getInstance(getClass().getName());
       }
   
   
  @@ -123,7 +130,7 @@
               // to a ConnectionPool, it means that it was taken from a pool
               // and not returned.  We log this fact, close the underlying
               // Connection, and return it to the ConnectionPool.
  -            Torque.getCategory().warn( "A TorqueConnection was finalized, "
  +            category.warn( "A TorqueConnection was finalized, "
                         + "without being returned "
                         + "to the ConnectionPool it belonged to" );
           }
  @@ -142,7 +149,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -172,7 +179,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -192,7 +199,7 @@
           catch (SQLException e)
           {
               e.printStackTrace();
  -            Torque.getCategory().error(e);
  +            category.error(e);
           }
           return stmt;
       }
  @@ -209,7 +216,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return stmt;
  @@ -225,7 +232,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return b;
  @@ -241,7 +248,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return catalog;
  @@ -257,7 +264,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return dmd;
  @@ -273,7 +280,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return level;
  @@ -289,7 +296,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return map;
  @@ -305,7 +312,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return warning;
  @@ -327,7 +334,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return b;
  @@ -343,7 +350,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return nativeSql;
  @@ -359,7 +366,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return stmt;
  @@ -377,7 +384,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return stmt;
  @@ -399,7 +406,7 @@
           }
           catch (SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return stmt;
  @@ -417,7 +424,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
           return stmt;
  @@ -435,7 +442,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -454,7 +461,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -468,7 +475,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -482,7 +489,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -496,7 +503,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  @@ -510,7 +517,7 @@
           }
           catch(SQLException e)
           {
  -            Torque.getCategory().error(e);
  +            category.error(e);
               throw e;
           }
       }
  
  
  

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

Reply via email to