You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mp...@apache.org on 2002/07/05 10:34:05 UTC

cvs commit: jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool TorqueClassicDataSource.java ConnectionWaitTimeoutException.java ConnectionPool.java CPDSConnectionFactory.java

mpoeschl    2002/07/05 01:34:05

  Modified:    jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter
                        PooledConnectionImpl.java DriverAdapterCPDS.java
                        ConnectionImpl.java
               jdbc2pool/src/java/org/apache/commons/jdbc2pool
                        TorqueClassicDataSource.java
                        ConnectionWaitTimeoutException.java
                        ConnectionPool.java CPDSConnectionFactory.java
  Log:
  cleanup imports
  
  Revision  Changes    Path
  1.5       +28 -35    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/PooledConnectionImpl.java
  
  Index: PooledConnectionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/PooledConnectionImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PooledConnectionImpl.java	3 Apr 2002 05:10:47 -0000	1.4
  +++ PooledConnectionImpl.java	5 Jul 2002 08:34:05 -0000	1.5
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -54,22 +54,15 @@
    * <http://www.apache.org/>.
    */
   
  -import java.util.Map;
  -import java.util.Iterator;
  -import java.util.EventObject;
  -import java.util.Vector;
   import java.sql.Connection;
  -import java.sql.DatabaseMetaData;
   import java.sql.PreparedStatement;
  -import java.sql.CallableStatement;
  -import java.sql.Statement;
  -import java.sql.SQLWarning;
   import java.sql.SQLException;
  +import java.util.Iterator;
  +import java.util.Vector;
   import javax.sql.ConnectionEvent;
   import javax.sql.ConnectionEventListener;
   import javax.sql.PooledConnection;
  -
  -import org.apache.commons.dbcp.*;
  +import org.apache.commons.dbcp.DelegatingPreparedStatement;
   import org.apache.commons.pool.KeyedObjectPool;
   import org.apache.commons.pool.KeyedPoolableObjectFactory;
   
  @@ -80,10 +73,10 @@
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @version $Id$
    */
  -public class PooledConnectionImpl 
  +public class PooledConnectionImpl
       implements PooledConnection, KeyedPoolableObjectFactory
   {
  -    private static final String CLOSED = 
  +    private static final String CLOSED =
           "Attempted to use PooledConnection after closed() was called.";
   
       /**
  @@ -134,17 +127,17 @@
       }
   
       /**
  -     * Closes the physical connection and marks this 
  -     * <code>PooledConnection</code> so that it may not be used 
  +     * Closes the physical connection and marks this
  +     * <code>PooledConnection</code> so that it may not be used
        * to generate any more logical <code>Connection</code>s.
        *
        * @exception SQLException if an error occurs
        */
       public void close()
           throws SQLException
  -    {        
  +    {
           isClosed = true;
  -        if(null != _pstmtPool) 
  +        if(null != _pstmtPool)
           {
               try
               {
  @@ -160,11 +153,11 @@
               }
               catch (Exception e)
               {
  -                if (e instanceof RuntimeException) 
  +                if (e instanceof RuntimeException)
                   {
                       throw (RuntimeException)e;
                   }
  -                else 
  +                else
                   {
                       throw new SQLException(e.getMessage());
                   }
  @@ -176,9 +169,9 @@
        * Throws an SQLException, if isClosed() is true
        */
       private void assertOpen()
  -        throws SQLException 
  +        throws SQLException
       {
  -        if ( isClosed ) 
  +        if ( isClosed )
           {
               throw new SQLException(CLOSED);
           }
  @@ -194,7 +187,7 @@
       {
           assertOpen();
           // make sure the last connection is marked as closed
  -        if ( logicalConnection != null && !logicalConnection.isClosed() ) 
  +        if ( logicalConnection != null && !logicalConnection.isClosed() )
           {
               // should notify pool of error so the pooled connection can
               // be removed !FIXME!
  @@ -233,11 +226,11 @@
           }
   
           // make sure the last connection is marked as closed
  -        if ( logicalConnection != null && !logicalConnection.isClosed() ) 
  +        if ( logicalConnection != null && !logicalConnection.isClosed() )
           {
               throw new SQLException("PooledConnection was gc'ed, without" +
                                      "its last Connection being closed.");
  -        }        
  +        }
       }
   
       /**
  @@ -247,7 +240,7 @@
       {
           ConnectionEvent event = new ConnectionEvent(this);
           Iterator i = eventListeners.iterator();
  -        while ( i.hasNext() ) 
  +        while ( i.hasNext() )
           {
               ((ConnectionEventListener)i.next()).connectionClosed(event);
           }
  @@ -260,7 +253,7 @@
        * Create or obtain a {*link PreparedStatement} from my pool.
        * @return a {*link PoolablePreparedStatement}
        */
  -    public PreparedStatement prepareStatement(String sql) 
  +    public PreparedStatement prepareStatement(String sql)
           throws SQLException {
           try {
               return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql)));
  @@ -275,8 +268,8 @@
        * Create or obtain a {*link PreparedStatement} from my pool.
        * @return a {*link PoolablePreparedStatement}
        */
  -    public PreparedStatement prepareStatement(String sql, int resultSetType, 
  -                                              int resultSetConcurrency) 
  +    public PreparedStatement prepareStatement(String sql, int resultSetType,
  +                                              int resultSetConcurrency)
           throws SQLException {
           try {
               return(PreparedStatement)(_pstmtPool.borrowObject(
  @@ -291,7 +284,7 @@
       /**
        * Create a {*link PoolingConnection.PStmtKey} for the given arguments.
        */
  -    protected Object createKey(String sql, int resultSetType, 
  +    protected Object createKey(String sql, int resultSetType,
                                  int resultSetConcurrency) {
           return new PStmtKey(normalizeSQL(sql), resultSetType,
                               resultSetConcurrency);
  @@ -324,8 +317,8 @@
               } else {
                   // _openPstmts++;
                   PStmtKey key = (PStmtKey)obj;
  -                if(null == key._resultSetType && null == 
  -                   key._resultSetConcurrency) 
  +                if(null == key._resultSetType && null ==
  +                   key._resultSetConcurrency)
                   {
                       return new PoolablePreparedStatementStub(
                           connection.prepareStatement(key._sql),
  
  
  
  1.5       +89 -94    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/DriverAdapterCPDS.java
  
  Index: DriverAdapterCPDS.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/DriverAdapterCPDS.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DriverAdapterCPDS.java	18 Mar 2002 06:33:01 -0000	1.4
  +++ DriverAdapterCPDS.java	5 Jul 2002 08:34:05 -0000	1.5
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -53,50 +53,45 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.Map;
   
  -import java.util.Hashtable;
  -import  java.io.PrintWriter;
  -import  java.io.Serializable;
  +import java.io.PrintWriter;
  +import java.io.Serializable;
   import java.sql.DriverManager;
   import java.sql.SQLException;
  -import javax.sql.PooledConnection;
  -import javax.sql.ConnectionPoolDataSource;
  -import javax.naming.Name;
  +import java.util.Hashtable;
   import javax.naming.Context;
  -import javax.naming.Referenceable;
  -import javax.naming.spi.ObjectFactory;
  -import javax.naming.Reference;
  +import javax.naming.Name;
  +import javax.naming.NamingException;
   import javax.naming.RefAddr;
  +import javax.naming.Reference;
  +import javax.naming.Referenceable;
   import javax.naming.StringRefAddr;
  -import javax.naming.NamingException;
  -
  +import javax.naming.spi.ObjectFactory;
  +import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.PooledConnection;
   import org.apache.commons.pool.KeyedObjectPool;
   import org.apache.commons.pool.impl.GenericKeyedObjectPool;
   
   /**
    * An adapter for jdbc drivers that do not include an implementation
  - * of ConnectionPoolDataSource.  This DataSource uses the old 
  + * of ConnectionPoolDataSource.  This DataSource uses the old
    * DriverManager implementation
    *
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @version $Id$
    */
   public class DriverAdapterCPDS
  -    implements ConnectionPoolDataSource, Referenceable, Serializable, 
  +    implements ConnectionPoolDataSource, Referenceable, Serializable,
                  ObjectFactory
   {
  -    private static final String GET_CONNECTION_CALLED = 
  -        "A PooledConnection was already requested from this source, " + 
  +    private static final String GET_CONNECTION_CALLED =
  +        "A PooledConnection was already requested from this source, " +
           "further initialization is not allowed.";
   
       /**
        * Default no-arg constructor for Serialization
        */
  -    public DriverAdapterCPDS() 
  +    public DriverAdapterCPDS()
       {
       }
   
  @@ -104,32 +99,32 @@
        * Attempt to establish a database connection using the default
        * user and password.
        */
  -    public PooledConnection getPooledConnection() 
  +    public PooledConnection getPooledConnection()
           throws SQLException
       {
           return getPooledConnection(getUser(), getPassword());
       }
  -                     
  +
       /**
        * Attempt to establish a database connection.
        */
  -    public PooledConnection getPooledConnection(String username, 
  +    public PooledConnection getPooledConnection(String username,
                                                   String password)
           throws SQLException
       {
           getConnectionCalled = true;
           /*
  -        public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory, 
  -        int maxActive, byte whenExhaustedAction, long maxWait, 
  -        int maxIdle, boolean testOnBorrow, boolean testOnReturn, 
  -        long timeBetweenEvictionRunsMillis, 
  -        int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, 
  +        public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory,
  +        int maxActive, byte whenExhaustedAction, long maxWait,
  +        int maxIdle, boolean testOnBorrow, boolean testOnReturn,
  +        long timeBetweenEvictionRunsMillis,
  +        int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
           boolean testWhileIdle) {
           */
           KeyedObjectPool stmtPool = new GenericKeyedObjectPool(null,
  -            getMaxActive(), GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 0, 
  -            getMaxIdle(), false, false, getTimeBetweenEvictionRunsMillis(), 
  -            getNumTestsPerEvictionRun(), 
  +            getMaxActive(), GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 0,
  +            getMaxIdle(), false, false, getTimeBetweenEvictionRunsMillis(),
  +            getNumTestsPerEvictionRun(),
               getMinEvictableIdleTimeMillis(), false);
   
           // Workaround for buggy WebLogic 5.1 classloader - ignore the
  @@ -151,36 +146,36 @@
       }
   
       // ----------------------------------------------------------------------
  -    // Referenceable implementation 
  +    // Referenceable implementation
   
       /**
        * <CODE>Referenceable</CODE> implementation.
        */
  -    public Reference getReference() 
  -        throws NamingException 
  +    public Reference getReference()
  +        throws NamingException
       {
           // this class implements its own factory
           String factory = getClass().getName();
  -        
  +
           Reference ref = new Reference(getClass().getName(), factory, null);
   
           ref.add(new StringRefAddr("description", getDescription()));
           ref.add(new StringRefAddr("driver", getDriver()));
  -        ref.add(new StringRefAddr("loginTimeout", 
  +        ref.add(new StringRefAddr("loginTimeout",
                                     String.valueOf(getLoginTimeout())));
           ref.add(new StringRefAddr("password", getPassword()));
           ref.add(new StringRefAddr("user", getUser()));
           ref.add(new StringRefAddr("url", getUrl()));
   
  -        ref.add(new StringRefAddr("maxActive", 
  +        ref.add(new StringRefAddr("maxActive",
                                     String.valueOf(getMaxActive())));
  -        ref.add(new StringRefAddr("maxIdle", 
  +        ref.add(new StringRefAddr("maxIdle",
                                     String.valueOf(getMaxIdle())));
  -        ref.add(new StringRefAddr("timeBetweenEvictionRunsMillis", 
  +        ref.add(new StringRefAddr("timeBetweenEvictionRunsMillis",
               String.valueOf(getTimeBetweenEvictionRunsMillis())));
  -        ref.add(new StringRefAddr("numTestsPerEvictionRun", 
  +        ref.add(new StringRefAddr("numTestsPerEvictionRun",
               String.valueOf(getNumTestsPerEvictionRun())));
  -        ref.add(new StringRefAddr("minEvictableIdleTimeMillis", 
  +        ref.add(new StringRefAddr("minEvictableIdleTimeMillis",
               String.valueOf(getMinEvictableIdleTimeMillis())));
   
           return ref;
  @@ -188,80 +183,80 @@
   
   
       // ----------------------------------------------------------------------
  -    // ObjectFactory implementation 
  +    // ObjectFactory implementation
   
       /**
        * implements ObjectFactory to create an instance of this class
  -     */ 
  -    public Object getObjectInstance(Object refObj, Name name, 
  -                                    Context context, Hashtable env) 
  -        throws Exception 
  +     */
  +    public Object getObjectInstance(Object refObj, Name name,
  +                                    Context context, Hashtable env)
  +        throws Exception
       {
  -        // The spec says to return null if we can't create an instance 
  +        // The spec says to return null if we can't create an instance
           // of the reference
           DriverAdapterCPDS cpds = null;
  -        if (refObj instanceof Reference) 
  +        if (refObj instanceof Reference)
           {
               Reference ref = (Reference)refObj;
  -            if (ref.getClassName().equals(getClass().getName())) 
  +            if (ref.getClassName().equals(getClass().getName()))
               {
                   RefAddr ra = ref.get("description");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setDescription(ra.getContent().toString());
                   }
   
                   ra = ref.get("driver");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setDriver(ra.getContent().toString());
                   }
                   ra = ref.get("url");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setUrl(ra.getContent().toString());
                   }
                   ra = ref.get("user");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setUser(ra.getContent().toString());
                   }
                   ra = ref.get("password");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setPassword(ra.getContent().toString());
                   }
   
                   ra = ref.get("maxActive");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setMaxActive(
                           Integer.parseInt(ra.getContent().toString()));
                   }
   
                   ra = ref.get("maxIdle");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setMaxIdle(
                           Integer.parseInt(ra.getContent().toString()));
                   }
   
                   ra = ref.get("timeBetweenEvictionRunsMillis");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setTimeBetweenEvictionRunsMillis(
                           Integer.parseInt(ra.getContent().toString()));
                   }
   
                   ra = ref.get("numTestsPerEvictionRun");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setNumTestsPerEvictionRun(
                           Integer.parseInt(ra.getContent().toString()));
                   }
   
                   ra = ref.get("minEvictableIdleTimeMillis");
  -                if (ra != null && ra.getContent() != null) 
  +                if (ra != null && ra.getContent() != null)
                   {
                       setMinEvictableIdleTimeMillis(
                           Integer.parseInt(ra.getContent().toString()));
  @@ -278,9 +273,9 @@
        * been requested.
        */
       private void assertInitializationAllowed()
  -        throws IllegalStateException 
  +        throws IllegalStateException
       {
  -        if (getConnectionCalled) 
  +        if (getConnectionCalled)
           {
               throw new IllegalStateException(GET_CONNECTION_CALLED);
           }
  @@ -288,7 +283,7 @@
   
       // ----------------------------------------------------------------------
       // Properties
  -    
  +
       /**
        * Get the value of description.  This property is here for use by
        * the code which will deploy this datasource.  It is not used
  @@ -296,11 +291,11 @@
        *
        * @return value of description.
        */
  -    public String getDescription() 
  +    public String getDescription()
       {
           return description;
       }
  -    
  +
       /**
        * Set the value of description.  This property is here for use by
        * the code which will deploy this datasource.  It is not used
  @@ -308,7 +303,7 @@
        *
        * @param v  Value to assign to description.
        */
  -    public void setDescription(String  v) 
  +    public void setDescription(String  v)
       {
           this.description = v;
       }
  @@ -317,16 +312,16 @@
        * Get the value of password for the default user.
        * @return value of password.
        */
  -    public String getPassword() 
  +    public String getPassword()
       {
           return password;
       }
  -    
  +
       /**
        * Set the value of password for the default user.
        * @param v  Value to assign to password.
        */
  -    public void setPassword(String  v) 
  +    public void setPassword(String  v)
       {
           assertInitializationAllowed();
           this.password = v;
  @@ -336,16 +331,16 @@
        * Get the value of url used to locate the database for this datasource.
        * @return value of url.
        */
  -    public String getUrl() 
  +    public String getUrl()
       {
           return url;
       }
  -    
  +
       /**
        * Set the value of url used to locate the database for this datasource.
        * @param v  Value to assign to url.
        */
  -    public void setUrl(String  v) 
  +    public void setUrl(String  v)
       {
           assertInitializationAllowed();
           this.url = v;
  @@ -355,16 +350,16 @@
        * Get the value of default user (login or username).
        * @return value of user.
        */
  -    public String getUser() 
  +    public String getUser()
       {
           return user;
       }
  -    
  +
       /**
        * Set the value of default user (login or username).
        * @param v  Value to assign to user.
        */
  -    public void setUser(String  v) 
  +    public void setUser(String  v)
       {
           assertInitializationAllowed();
           this.user = v;
  @@ -374,13 +369,13 @@
        * Get the driver classname.
        * @return value of driver.
        */
  -    public String getDriver() 
  +    public String getDriver()
       {
           return driver;
       }
  -    
  +
       /**
  -     * Set the driver classname.  Setting the driver classname cause the 
  +     * Set the driver classname.  Setting the driver classname cause the
        * driver to be registered with the DriverManager.
        * @param v  Value to assign to driver.
        */
  @@ -392,40 +387,40 @@
           // make sure driver is registered
           Class.forName(v);
       }
  -    
  +
       /**
  -     * Gets the maximum time in seconds that this data source can wait 
  +     * Gets the maximum time in seconds that this data source can wait
        * while attempting to connect to a database. NOT USED.
        */
  -    public int getLoginTimeout() 
  +    public int getLoginTimeout()
       {
           return loginTimeout;
       }
  -                           
  +
       /**
        * Get the log writer for this data source. NOT USED.
        */
  -    public PrintWriter getLogWriter() 
  +    public PrintWriter getLogWriter()
       {
           return logWriter;
       }
  -                           
  +
       /**
  -     * Sets the maximum time in seconds that this data source will wait 
  +     * Sets the maximum time in seconds that this data source will wait
        * while attempting to connect to a database. NOT USED.
        */
       public void setLoginTimeout(int seconds)
       {
           loginTimeout = seconds;
  -    } 
  -                           
  +    }
  +
       /**
        * Set the log writer for this data source. NOT USED.
        */
       public void setLogWriter(java.io.PrintWriter out)
       {
           logWriter = out;
  -    } 
  +    }
   
   
       // ------------------------------------------------------------------
  @@ -485,7 +480,7 @@
        *
        * *see #getTimeBetweenEvictionRunsMillis
        */
  -    public void 
  +    public void
           setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
           assertInitializationAllowed();
               _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
  @@ -540,7 +535,7 @@
        * *see #getMinEvictableIdleTimeMillis
        * *see #setTimeBetweenEvictionRunsMillis
        */
  -    public void 
  +    public void
           setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
           assertInitializationAllowed();
           _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
  
  
  
  1.3       +51 -57    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/ConnectionImpl.java
  
  Index: ConnectionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/adapter/ConnectionImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionImpl.java	17 Jan 2002 05:44:26 -0000	1.2
  +++ ConnectionImpl.java	5 Jul 2002 08:34:05 -0000	1.3
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -55,7 +55,6 @@
    */
   
   import java.util.Map;
  -import java.io.PrintStream;
   import java.sql.Connection;
   import java.sql.DatabaseMetaData;
   import java.sql.PreparedStatement;
  @@ -63,17 +62,12 @@
   import java.sql.Statement;
   import java.sql.SQLWarning;
   import java.sql.SQLException;
  -import java.util.EventObject;
  -import java.util.Vector;
  -import javax.sql.ConnectionEvent;
  -import javax.sql.ConnectionEventListener;
  -import javax.sql.PooledConnection;
   
   /**
    * This class is used as the <code>Connection</code> that will be returned
    * from <code>PooledConnectionImpl.getConnection()</code>.  It expects a
    * <code>Connection</code> that is created by a jdbc 1.x driver or datasource
  - * as well as the PooleConnectionImpl that instantiated this object as 
  + * as well as the PooleConnectionImpl that instantiated this object as
    * arguments to the constructor.  All methods except for close() and isClosed()
    * are wrappers around the jdbc 1.x <code>Connection</code>.  close() will
    * result in the isClosed() method returning true as well as notifying the
  @@ -83,10 +77,10 @@
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @version $Id$
    */
  -public class ConnectionImpl 
  +public class ConnectionImpl
       implements Connection
   {
  -    private static final String CLOSED = 
  +    private static final String CLOSED =
           "Attempted to use Connection after closed() was called.";
   
       /**
  @@ -110,7 +104,7 @@
        * @param pooledConnection The PooledConnection that is calling the ctor.
        * @param connection The JDBC connection to wrap.
        */
  -    ConnectionImpl(PooledConnectionImpl pooledConnection, 
  +    ConnectionImpl(PooledConnectionImpl pooledConnection,
                      Connection connection)
       {
           this.pooledConnection = pooledConnection;
  @@ -141,9 +135,9 @@
        * Throws an SQLException, if isClosed() is true
        */
       private void assertOpen()
  -        throws SQLException 
  +        throws SQLException
       {
  -        if ( isClosed ) 
  +        if ( isClosed )
           {
               throw new SQLException(CLOSED);
           }
  @@ -159,8 +153,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public void clearWarnings() 
  -        throws SQLException 
  +    public void clearWarnings()
  +        throws SQLException
       {
           assertOpen();
           connection.clearWarnings();
  @@ -199,7 +193,7 @@
        * in the wrapped connection.
        */
       public Statement createStatement()
  -        throws SQLException 
  +        throws SQLException
       {
           assertOpen();
           return connection.createStatement();
  @@ -211,9 +205,9 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public Statement createStatement(int resultSetType, 
  -                                     int resultSetConcurrency) 
  -        throws SQLException 
  +    public Statement createStatement(int resultSetType,
  +                                     int resultSetConcurrency)
  +        throws SQLException
       {
           assertOpen();
           return connection
  @@ -226,8 +220,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public boolean getAutoCommit() 
  -        throws SQLException 
  +    public boolean getAutoCommit()
  +        throws SQLException
       {
           assertOpen();
           return connection.getAutoCommit();
  @@ -239,8 +233,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public String getCatalog() 
  -        throws SQLException 
  +    public String getCatalog()
  +        throws SQLException
       {
           assertOpen();
           return connection.getCatalog();
  @@ -252,8 +246,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public DatabaseMetaData getMetaData() 
  -        throws SQLException 
  +    public DatabaseMetaData getMetaData()
  +        throws SQLException
       {
           assertOpen();
           return connection.getMetaData();
  @@ -265,8 +259,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public int getTransactionIsolation() 
  -        throws SQLException 
  +    public int getTransactionIsolation()
  +        throws SQLException
       {
           assertOpen();
           return connection.getTransactionIsolation();
  @@ -278,8 +272,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public Map getTypeMap() 
  -        throws SQLException 
  +    public Map getTypeMap()
  +        throws SQLException
       {
           assertOpen();
           return connection.getTypeMap();
  @@ -291,8 +285,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public SQLWarning getWarnings() 
  -        throws SQLException 
  +    public SQLWarning getWarnings()
  +        throws SQLException
       {
           assertOpen();
           return connection.getWarnings();
  @@ -303,7 +297,7 @@
        *
        * @return a <code>boolean</code> value
        */
  -    public boolean isClosed() 
  +    public boolean isClosed()
       {
           return isClosed;
       }
  @@ -314,8 +308,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public boolean isReadOnly() 
  -        throws SQLException 
  +    public boolean isReadOnly()
  +        throws SQLException
       {
           assertOpen();
           return connection.isReadOnly();
  @@ -327,12 +321,12 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public String nativeSQL(String sql) 
  -        throws SQLException 
  +    public String nativeSQL(String sql)
  +        throws SQLException
       {
           assertOpen();
           return connection.nativeSQL(sql);
  -    }    
  +    }
   
       /**
        * Pass thru method to the wrapped jdbc 1.x {@link java.sql.Connection}.
  @@ -340,8 +334,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public CallableStatement prepareCall(String sql) 
  -        throws SQLException 
  +    public CallableStatement prepareCall(String sql)
  +        throws SQLException
       {
           assertOpen();
           return connection.prepareCall(sql);
  @@ -353,9 +347,9 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public CallableStatement prepareCall(String sql, int resultSetType, 
  -                                         int resultSetConcurrency) 
  -        throws SQLException 
  +    public CallableStatement prepareCall(String sql, int resultSetType,
  +                                         int resultSetConcurrency)
  +        throws SQLException
       {
           assertOpen();
           return connection
  @@ -381,9 +375,9 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public PreparedStatement prepareStatement(String sql, int resultSetType, 
  -                                              int resultSetConcurrency) 
  -        throws SQLException 
  +    public PreparedStatement prepareStatement(String sql, int resultSetType,
  +                                              int resultSetConcurrency)
  +        throws SQLException
       {
           assertOpen();
           return connection
  @@ -422,8 +416,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public void setCatalog(String catalog) 
  -        throws SQLException 
  +    public void setCatalog(String catalog)
  +        throws SQLException
       {
           assertOpen();
           connection.setCatalog(catalog);
  @@ -435,8 +429,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public void setReadOnly(boolean readOnly) 
  -        throws SQLException 
  +    public void setReadOnly(boolean readOnly)
  +        throws SQLException
       {
           assertOpen();
           connection.setReadOnly(readOnly);
  @@ -448,8 +442,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public void setTransactionIsolation(int level) 
  -        throws SQLException 
  +    public void setTransactionIsolation(int level)
  +        throws SQLException
       {
           assertOpen();
           connection.setTransactionIsolation(level);
  @@ -461,8 +455,8 @@
        * @exception SQLException if this connection is closed or an error occurs
        * in the wrapped connection.
        */
  -    public void setTypeMap(Map map) 
  -        throws SQLException 
  +    public void setTypeMap(Map map)
  +        throws SQLException
       {
           assertOpen();
           connection.setTypeMap(map);
  
  
  
  1.6       +12 -18    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/TorqueClassicDataSource.java
  
  Index: TorqueClassicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/TorqueClassicDataSource.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TorqueClassicDataSource.java	5 Jul 2002 08:23:04 -0000	1.5
  +++ TorqueClassicDataSource.java	5 Jul 2002 08:34:05 -0000	1.6
  @@ -54,32 +54,26 @@
    * <http://www.apache.org/>.
    */
   
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.Properties;
  -
  -import java.util.Hashtable;
   import java.io.PrintWriter;
   import java.io.Serializable;
  -import java.io.ByteArrayOutputStream;
  -import java.io.ObjectOutputStream;
  -import java.io.IOException;
   import java.sql.Connection;
   import java.sql.SQLException;
  -import javax.sql.DataSource;
  -import javax.sql.ConnectionPoolDataSource;
  -import javax.naming.Name;
  +import java.util.HashMap;
  +import java.util.Hashtable;
  +import java.util.Map;
  +import java.util.Properties;
  +import javax.naming.BinaryRefAddr;
   import javax.naming.Context;
   import javax.naming.InitialContext;
  -import javax.naming.Referenceable;
  -import javax.naming.Reference;
  +import javax.naming.Name;
  +import javax.naming.NamingException;
   import javax.naming.RefAddr;
  -import javax.naming.BinaryRefAddr;
  +import javax.naming.Reference;
  +import javax.naming.Referenceable;
   import javax.naming.StringRefAddr;
  -import javax.naming.NamingException;
   import javax.naming.spi.ObjectFactory;
  -
  +import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.DataSource;
   import org.apache.commons.lang.Serialization;
   
   /**
  
  
  
  1.3       +1 -2      jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/ConnectionWaitTimeoutException.java
  
  Index: ConnectionWaitTimeoutException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/ConnectionWaitTimeoutException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionWaitTimeoutException.java	17 Jan 2002 05:44:26 -0000	1.2
  +++ ConnectionWaitTimeoutException.java	5 Jul 2002 08:34:05 -0000	1.3
  @@ -54,7 +54,6 @@
    * <http://www.apache.org/>.
    */
   
  -import java.sql.SQLException;
   
   /**
    * Thrown to indicate that
  
  
  
  1.7       +36 -39    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/ConnectionPool.java
  
  Index: ConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/ConnectionPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConnectionPool.java	21 May 2002 19:42:47 -0000	1.6
  +++ ConnectionPool.java	5 Jul 2002 08:34:05 -0000	1.7
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -54,18 +54,15 @@
    * <http://www.apache.org/>.
    */
   
  -import java.util.Map;
  -import java.util.HashMap;
  -import java.util.Date;
   import java.io.PrintWriter;
  -import java.sql.Connection;
   import java.sql.SQLException;
  +import java.util.HashMap;
  +import java.util.Map;
   import java.util.Stack;
  -import java.util.Vector;
  -import javax.sql.ConnectionPoolDataSource;
  -import javax.sql.PooledConnection;
   import javax.sql.ConnectionEvent;
   import javax.sql.ConnectionEventListener;
  +import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.PooledConnection;
   
   /**
    * This class implements a simple connection pooling scheme.  Multiple
  @@ -147,7 +144,7 @@
       private ConnectionPoolDataSource cpds;
   
       /**
  -     * Keep track of when connections were created.  Keyed by a 
  +     * Keep track of when connections were created.  Keyed by a
        * PooledConnection and value is a java.util.Date
        */
       private Map timeStamps;
  @@ -171,37 +168,37 @@
           totalConnections = 0;
           pool = new Stack();
           timeStamps = new HashMap();
  -        
  +
           this.cpds = cpds;
           this.username = username;
           this.password = password;
  -        if ( maxConnections > 0 ) 
  +        if ( maxConnections > 0 )
           {
               this.maxConnections = maxConnections;
           }
  -        else 
  +        else
           {
  -            this.maxConnections = 1;            
  +            this.maxConnections = 1;
           }
  -        if ( expiryTime > 0 ) 
  +        if ( expiryTime > 0 )
           {
  -            this.expiryTime = expiryTime * 1000;            
  +            this.expiryTime = expiryTime * 1000;
           }
  -        else 
  +        else
           {
               this.expiryTime = 3600 * 1000; // one hour
           }
  -        if ( connectionWaitTimeout > 0 ) 
  +        if ( connectionWaitTimeout > 0 )
           {
  -            this.connectionWaitTimeout = connectionWaitTimeout * 1000;    
  +            this.connectionWaitTimeout = connectionWaitTimeout * 1000;
           }
           else
           {
               this.connectionWaitTimeout = 10 * 1000; // ten seconds
           }
  -        this.logInterval = logInterval * 1000;    
  -        this.logWriter = logWriter;        
  - 
  +        this.logInterval = logInterval * 1000;
  +        this.logWriter = logWriter;
  +
           // Create monitor thread
           monitor = new Monitor();
           // Indicate that this is a system thread. JVM will quit only when there
  @@ -224,15 +221,15 @@
        *
        * @exception SQLException
        */
  -    synchronized final PooledConnection 
  +    synchronized final PooledConnection
           getConnection(String username, String password)
           throws SQLException
       {
  -        if ( username != this.username || password != this.password ) 
  +        if ( username != this.username || password != this.password )
           {
               throw new SQLException("Username and password are invalid.");
           }
  -        
  +
           PooledConnection pcon = null;
           if ( pool.empty() && totalConnections < maxConnections )
           {
  @@ -265,11 +262,11 @@
           throws SQLException
       {
           PooledConnection pc = null;
  -        if ( username == null ) 
  +        if ( username == null )
           {
               pc = cpds.getPooledConnection();
           }
  -        else 
  +        else
           {
               pc = cpds.getPooledConnection(username, password);
           }
  @@ -497,7 +494,7 @@
        * method of this connection object. What we need to do here is to
        * release this PooledConnection from our pool...
        */
  -    public void connectionClosed(ConnectionEvent event) 
  +    public void connectionClosed(ConnectionEvent event)
       {
           releaseConnection( (PooledConnection)event.getSource());
       }
  @@ -506,27 +503,27 @@
        * If a fatal error occurs, close the underlying physical connection so as
        * not to be returned in the future
        */
  -    public void connectionErrorOccurred(ConnectionEvent event) 
  +    public void connectionErrorOccurred(ConnectionEvent event)
       {
  -        try 
  +        try
           {
               System.err
                   .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR");
  -            //remove this from the listener list because we are no more 
  +            //remove this from the listener list because we are no more
               //interested in errors since we are about to close this connection
               ( (PooledConnection) event.getSource() )
                   .removeConnectionEventListener(this);
           }
  -        catch (Exception ignore) 
  +        catch (Exception ignore)
           {
               //just ignore
           }
   
  -        try 
  +        try
           {
               closePooledConnection( (PooledConnection)event.getSource() );
           }
  -        catch (Exception ignore) 
  +        catch (Exception ignore)
           {
               //just ignore
           }
  @@ -571,11 +568,11 @@
   
       private void log(String s)
       {
  -        if ( logWriter != null ) 
  +        if ( logWriter != null )
           {
               logWriter.println(s);
           }
  -        else 
  +        else
           {
               System.out.println(s);
           }
  
  
  
  1.4       +32 -30    jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/CPDSConnectionFactory.java
  
  Index: CPDSConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jdbc2pool/src/java/org/apache/commons/jdbc2pool/CPDSConnectionFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CPDSConnectionFactory.java	19 May 2002 22:56:18 -0000	1.3
  +++ CPDSConnectionFactory.java	5 Jul 2002 08:34:05 -0000	1.4
  @@ -61,16 +61,18 @@
   
   package org.apache.commons.jdbc2pool;
   
  -import java.util.Map;
  +import java.sql.Connection;
  +import java.sql.ResultSet;
  +import java.sql.SQLException;
  +import java.sql.Statement;
   import java.util.HashMap;
  -import java.sql.*;
  -import javax.sql.ConnectionPoolDataSource;
  -import javax.sql.PooledConnection;
  +import java.util.Map;
   import javax.sql.ConnectionEvent;
   import javax.sql.ConnectionEventListener;
  -
  -import org.apache.commons.pool.*;
  -import org.apache.commons.dbcp.*;
  +import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.PooledConnection;
  +import org.apache.commons.pool.ObjectPool;
  +import org.apache.commons.pool.PoolableObjectFactory;
   
   /**
    * A {*link PoolableObjectFactory} that creates
  @@ -79,18 +81,18 @@
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    * @version $Id$
    */
  -public class CPDSConnectionFactory 
  +public class CPDSConnectionFactory
       implements PoolableObjectFactory, ConnectionEventListener {
       /**
        * Create a new <tt>PoolableConnectionFactory</tt>.
        * @param cpds the ConnectionPoolDataSource from which to obtain PooledConnection's
        * @param pool the {*link ObjectPool} in which to pool those {*link Connection}s
        * @param validationQuery a query to use to {*link #validateObject validate} {*link Connection}s.  Should return at least one row. May be <tt>null</tt>
  -     * @param username 
  +     * @param username
        * @param password
        */
  -    public CPDSConnectionFactory(ConnectionPoolDataSource cpds, 
  -                                 ObjectPool pool, 
  +    public CPDSConnectionFactory(ConnectionPoolDataSource cpds,
  +                                 ObjectPool pool,
                                    String validationQuery,
                                    String username,
                                    String password) {
  @@ -124,7 +126,7 @@
        * Sets the {*link ObjectPool} in which to pool {*link Connection}s.
        * @param pool the {*link ObjectPool} in which to pool those {*link Connection}s
        */
  -    synchronized public void setPool(ObjectPool pool) 
  +    synchronized public void setPool(ObjectPool pool)
           throws SQLException
       {
           if(null != _pool && pool != _pool) {
  @@ -134,11 +136,11 @@
               }
               catch (Exception e)
               {
  -                if (e instanceof RuntimeException) 
  +                if (e instanceof RuntimeException)
                   {
                       throw (RuntimeException)e;
                   }
  -                else 
  +                else
                   {
                       throw new SQLException(e.getMessage());
                   }
  @@ -156,11 +158,11 @@
           PooledConnection pc = null;
           try
           {
  -            if ( _username == null ) 
  +            if ( _username == null )
               {
                   pc = _cpds.getPooledConnection();
               }
  -            else 
  +            else
               {
                   pc = _cpds.getPooledConnection(_username, _password);
               }
  @@ -197,9 +199,9 @@
                   Statement stmt = null;
                   ResultSet rset = null;
                   // logical Connection from the PooledConnection must be closed
  -                // before another one can be requested and closing it will 
  +                // before another one can be requested and closing it will
                   // generate an event. Keep track so we know not to return
  -                // the PooledConnection 
  +                // the PooledConnection
                   validatingMap.put(pconn, null);
                   try {
                       conn = pconn.getConnection();
  @@ -213,7 +215,7 @@
                   } catch(Exception e) {
                       valid = false;
                   }
  -                finally 
  +                finally
                   {
                       try {
                           rset.close();
  @@ -257,12 +259,12 @@
        * method of this connection object. What we need to do here is to
        * release this PooledConnection from our pool...
        */
  -    public void connectionClosed(ConnectionEvent event) 
  +    public void connectionClosed(ConnectionEvent event)
       {
           PooledConnection pc = (PooledConnection)event.getSource();
           // if this event occured becase we were validating, ignore it
           // otherwise return the connection to the pool.
  -        if (!validatingMap.containsKey(pc)) 
  +        if (!validatingMap.containsKey(pc))
           {
               try
               {
  @@ -271,7 +273,7 @@
               catch (Exception e)
               {
                   destroyObject(pc);
  -                System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + 
  +                System.err.println("CLOSING DOWN CONNECTION AS IT COULD " +
                                      "NOT BE RETURNED TO THE POOL");
               }
           }
  @@ -281,18 +283,18 @@
        * If a fatal error occurs, close the underlying physical connection so as
        * not to be returned in the future
        */
  -    public void connectionErrorOccurred(ConnectionEvent event) 
  +    public void connectionErrorOccurred(ConnectionEvent event)
       {
           PooledConnection pc = (PooledConnection)event.getSource();
  -        try 
  +        try
           {
               System.err
                   .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR");
  -            //remove this from the listener list because we are no more 
  +            //remove this from the listener list because we are no more
               //interested in errors since we are about to close this connection
               pc.removeConnectionEventListener(this);
           }
  -        catch (Exception ignore) 
  +        catch (Exception ignore)
           {
               // ignore
           }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>