User: mulder  
  Date: 00/08/30 09:17:06

  Modified:    src/main/org/jboss/minerva/jdbc ConnectionInPool.java
                        ResultSetInPool.java StatementInPool.java
  Added:       src/main/org/jboss/minerva/jdbc PSCacheKey.java
  Log:
  Cache PreparedStatements for each Connection.  The JDBC 1/2 wrappers
  automatically clean this up for each Connection as it is closed.  We need
  to think about how to handle clearing the cache when a Connection is closed
  for a native JDBC 2 Standard Extension implementation.
  
  Revision  Changes    Path
  1.2       +36 -6     jboss/src/main/org/jboss/minerva/jdbc/ConnectionInPool.java
  
  Index: ConnectionInPool.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/jdbc/ConnectionInPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionInPool.java     2000/06/02 13:48:43     1.1
  +++ ConnectionInPool.java     2000/08/30 16:17:05     1.2
  @@ -6,9 +6,21 @@
    */
   package org.jboss.minerva.jdbc;
   
  -import java.sql.*;
  -import java.util.*;
  -import org.jboss.minerva.pools.*;
  +import java.sql.CallableStatement;
  +import java.sql.Connection;
  +import java.sql.DatabaseMetaData;
  +import java.sql.PreparedStatement;
  +import java.sql.SQLException;
  +import java.sql.SQLWarning;
  +import java.sql.Statement;
  +import java.util.Collection;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Vector;
  +import org.jboss.minerva.pools.PooledObject;
  +import org.jboss.minerva.pools.PoolEvent;
  +import org.jboss.minerva.pools.PoolEventListener;
   
   /**
    * Wrapper for database connections in a pool.  Handles closing appropriately.
  @@ -16,7 +28,7 @@
    * outstanding statements are closed, and the connection is rolled back.  This
    * class is also used by statements, etc. to update the last used time for the
    * connection.
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class ConnectionInPool implements PooledObject, ConnectionWrapper {
  @@ -143,7 +155,16 @@
       public PreparedStatement prepareStatement(String sql) throws SQLException {
           if(con == null) throw new SQLException(CLOSED);
           try {
  -            return con.prepareStatement(sql);
  +            PreparedStatement ps = 
(PreparedStatement)PreparedStatementInPool.preparedStatementCache.get(
  +                                        new PSCacheKey(con, sql));
  +            if(ps == null) {
  +                ps = con.prepareStatement(sql);
  +                PreparedStatementInPool.preparedStatementCache.put(
  +                                        new PSCacheKey(con, sql), ps);
  +            }
  +            PreparedStatementInPool wrapper = new PreparedStatementInPool(ps, this);
  +            statements.add(wrapper);
  +            return wrapper;
           } catch(SQLException e) {
               setError(e);
               throw e;
  @@ -331,7 +352,16 @@
       public PreparedStatement prepareStatement(String sql, int resultSetType, int 
resultSetConcurrency) throws SQLException {
           if(con == null) throw new SQLException(CLOSED);
           try {
  -            return con.prepareStatement(sql, resultSetType, resultSetConcurrency);
  +            PreparedStatement ps = 
(PreparedStatement)PreparedStatementInPool.preparedStatementCache.get(
  +                                        new PSCacheKey(con, sql));
  +            if(ps == null) {
  +                ps = con.prepareStatement(sql, resultSetType, resultSetConcurrency);
  +                PreparedStatementInPool.preparedStatementCache.put(
  +                                        new PSCacheKey(con, sql), ps);
  +            }
  +            PreparedStatementInPool wrapper = new PreparedStatementInPool(ps, this);
  +            statements.add(wrapper);
  +            return wrapper;
           } catch(SQLException e) {
               setError(e);
               throw e;
  
  
  
  1.2       +143 -132  jboss/src/main/org/jboss/minerva/jdbc/ResultSetInPool.java
  
  Index: ResultSetInPool.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/jdbc/ResultSetInPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResultSetInPool.java      2000/06/02 13:48:43     1.1
  +++ ResultSetInPool.java      2000/08/30 16:17:05     1.2
  @@ -6,13 +6,24 @@
    */
   package org.jboss.minerva.jdbc;
   
  -import java.sql.*;
  +import java.sql.Array;
  +import java.sql.Blob;
  +import java.sql.Clob;
  +import java.sql.Date;
  +import java.sql.Ref;
  +import java.sql.ResultSet;
  +import java.sql.ResultSetMetaData;
  +import java.sql.SQLException;
  +import java.sql.SQLWarning;
  +import java.sql.Statement;
  +import java.sql.Time;
  +import java.sql.Timestamp;
   
   /**
    * Wraps a result set to track the last used time for the owning connection.
    * That time is updated every time a navigation action is performed on the
    * result set (next, previous, etc.).
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class ResultSetInPool implements ResultSet {
  @@ -55,35 +66,35 @@
   
       // ---- Implementation of java.sql.ResultSet ----
   
  -    public boolean absolute(int arg0) throws java.sql.SQLException {
  +    public boolean absolute(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.absolute(arg0);
       }
   
  -    public void afterLast() throws java.sql.SQLException {
  +    public void afterLast() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.afterLast();
       }
   
  -    public void beforeFirst() throws java.sql.SQLException {
  +    public void beforeFirst() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.beforeFirst();
       }
   
  -    public void cancelRowUpdates() throws java.sql.SQLException {
  +    public void cancelRowUpdates() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.cancelRowUpdates();
       }
   
  -    public void clearWarnings() throws java.sql.SQLException {
  +    public void clearWarnings() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.clearWarnings();
       }
   
  -    public void close() throws java.sql.SQLException {
  +    public void close() throws SQLException {
           if(impl != null) {
               impl.close();
               impl = null;
  @@ -91,631 +102,631 @@
           st = null;
       }
   
  -    public void deleteRow() throws java.sql.SQLException {
  +    public void deleteRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.deleteRow();
       }
   
  -    public int findColumn(String arg0) throws java.sql.SQLException {
  +    public int findColumn(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.findColumn(arg0);
       }
   
  -    public boolean first() throws java.sql.SQLException {
  +    public boolean first() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.first();
       }
   
  -    public java.sql.Array getArray(int arg0) throws java.sql.SQLException {
  +    public Array getArray(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getArray(arg0);
       }
   
  -    public java.sql.Array getArray(String arg0) throws java.sql.SQLException {
  +    public Array getArray(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getArray(arg0);
       }
   
  -    public java.io.InputStream getAsciiStream(int arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getAsciiStream(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getAsciiStream(arg0);
       }
   
  -    public java.io.InputStream getAsciiStream(String arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getAsciiStream(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getAsciiStream(arg0);
       }
   
  -    public java.math.BigDecimal getBigDecimal(int arg0) throws 
java.sql.SQLException {
  +    public java.math.BigDecimal getBigDecimal(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBigDecimal(arg0);
       }
   
  -    public java.math.BigDecimal getBigDecimal(int arg0, int arg1) throws 
java.sql.SQLException {
  +    public java.math.BigDecimal getBigDecimal(int arg0, int arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBigDecimal(arg0, arg1);
       }
   
  -    public java.math.BigDecimal getBigDecimal(String arg0) throws 
java.sql.SQLException {
  +    public java.math.BigDecimal getBigDecimal(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBigDecimal(arg0);
       }
   
  -    public java.math.BigDecimal getBigDecimal(String arg0, int arg1) throws 
java.sql.SQLException {
  +    public java.math.BigDecimal getBigDecimal(String arg0, int arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBigDecimal(arg0, arg1);
       }
   
  -    public java.io.InputStream getBinaryStream(int arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getBinaryStream(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBinaryStream(arg0);
       }
   
  -    public java.io.InputStream getBinaryStream(String arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getBinaryStream(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBinaryStream(arg0);
       }
   
  -    public java.sql.Blob getBlob(int arg0) throws java.sql.SQLException {
  +    public Blob getBlob(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBlob(arg0);
       }
   
  -    public java.sql.Blob getBlob(String arg0) throws java.sql.SQLException {
  +    public Blob getBlob(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBlob(arg0);
       }
   
  -    public boolean getBoolean(int arg0) throws java.sql.SQLException {
  +    public boolean getBoolean(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBoolean(arg0);
       }
   
  -    public boolean getBoolean(String arg0) throws java.sql.SQLException {
  +    public boolean getBoolean(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBoolean(arg0);
       }
   
  -    public byte getByte(int arg0) throws java.sql.SQLException {
  +    public byte getByte(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getByte(arg0);
       }
   
  -    public byte getByte(String arg0) throws java.sql.SQLException {
  +    public byte getByte(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getByte(arg0);
       }
   
  -    public byte[] getBytes(int arg0) throws java.sql.SQLException {
  +    public byte[] getBytes(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBytes(arg0);
       }
   
  -    public byte[] getBytes(String arg0) throws java.sql.SQLException {
  +    public byte[] getBytes(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getBytes(arg0);
       }
   
  -    public java.io.Reader getCharacterStream(int arg0) throws java.sql.SQLException 
{
  +    public java.io.Reader getCharacterStream(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getCharacterStream(arg0);
       }
   
  -    public java.io.Reader getCharacterStream(String arg0) throws 
java.sql.SQLException {
  +    public java.io.Reader getCharacterStream(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getCharacterStream(arg0);
       }
   
  -    public java.sql.Clob getClob(int arg0) throws java.sql.SQLException {
  +    public Clob getClob(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getClob(arg0);
       }
   
  -    public java.sql.Clob getClob(String arg0) throws java.sql.SQLException {
  +    public Clob getClob(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getClob(arg0);
       }
   
  -    public int getConcurrency() throws java.sql.SQLException {
  +    public int getConcurrency() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getConcurrency();
       }
   
  -    public String getCursorName() throws java.sql.SQLException {
  +    public String getCursorName() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getCursorName();
       }
   
  -    public java.sql.Date getDate(int arg0) throws java.sql.SQLException {
  +    public Date getDate(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDate(arg0);
       }
   
  -    public java.sql.Date getDate(int arg0, java.util.Calendar arg1) throws 
java.sql.SQLException {
  +    public Date getDate(int arg0, java.util.Calendar arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDate(arg0, arg1);
       }
   
  -    public java.sql.Date getDate(String arg0) throws java.sql.SQLException {
  +    public Date getDate(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDate(arg0);
       }
   
  -    public java.sql.Date getDate(String arg0, java.util.Calendar arg1) throws 
java.sql.SQLException {
  +    public Date getDate(String arg0, java.util.Calendar arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDate(arg0, arg1);
       }
   
  -    public double getDouble(int arg0) throws java.sql.SQLException {
  +    public double getDouble(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDouble(arg0);
       }
   
  -    public double getDouble(String arg0) throws java.sql.SQLException {
  +    public double getDouble(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getDouble(arg0);
       }
   
  -    public int getFetchDirection() throws java.sql.SQLException {
  +    public int getFetchDirection() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getFetchDirection();
       }
   
  -    public int getFetchSize() throws java.sql.SQLException {
  +    public int getFetchSize() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getFetchSize();
       }
   
  -    public float getFloat(int arg0) throws java.sql.SQLException {
  +    public float getFloat(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getFloat(arg0);
       }
   
  -    public float getFloat(String arg0) throws java.sql.SQLException {
  +    public float getFloat(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getFloat(arg0);
       }
   
  -    public int getInt(int arg0) throws java.sql.SQLException {
  +    public int getInt(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getInt(arg0);
       }
   
  -    public int getInt(String arg0) throws java.sql.SQLException {
  +    public int getInt(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getInt(arg0);
       }
   
  -    public long getLong(int arg0) throws java.sql.SQLException {
  +    public long getLong(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getLong(arg0);
       }
   
  -    public long getLong(String arg0) throws java.sql.SQLException {
  +    public long getLong(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getLong(arg0);
       }
   
  -    public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException {
  +    public ResultSetMetaData getMetaData() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getMetaData();
       }
   
  -    public Object getObject(int arg0) throws java.sql.SQLException {
  +    public Object getObject(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getObject(arg0);
       }
   
  -    public Object getObject(int arg0, java.util.Map arg1) throws 
java.sql.SQLException {
  +    public Object getObject(int arg0, java.util.Map arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getObject(arg0, arg1);
       }
   
  -    public Object getObject(String arg0) throws java.sql.SQLException {
  +    public Object getObject(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getObject(arg0);
       }
   
  -    public Object getObject(String arg0, java.util.Map arg1) throws 
java.sql.SQLException {
  +    public Object getObject(String arg0, java.util.Map arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getObject(arg0, arg1);
       }
   
  -    public java.sql.Ref getRef(int arg0) throws java.sql.SQLException {
  +    public Ref getRef(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getRef(arg0);
       }
   
  -    public java.sql.Ref getRef(String arg0) throws java.sql.SQLException {
  +    public Ref getRef(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getRef(arg0);
       }
   
  -    public int getRow() throws java.sql.SQLException {
  +    public int getRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getRow();
       }
   
  -    public short getShort(int arg0) throws java.sql.SQLException {
  +    public short getShort(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getShort(arg0);
       }
   
  -    public short getShort(String arg0) throws java.sql.SQLException {
  +    public short getShort(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getShort(arg0);
       }
   
  -    public java.sql.Statement getStatement() throws java.sql.SQLException {
  +    public Statement getStatement() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getStatement();
       }
   
  -    public String getString(int arg0) throws java.sql.SQLException {
  +    public String getString(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getString(arg0);
       }
   
  -    public String getString(String arg0) throws java.sql.SQLException {
  +    public String getString(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getString(arg0);
       }
   
  -    public java.sql.Time getTime(int arg0) throws java.sql.SQLException {
  +    public Time getTime(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTime(arg0);
       }
   
  -    public java.sql.Time getTime(int arg0, java.util.Calendar arg1) throws 
java.sql.SQLException {
  +    public Time getTime(int arg0, java.util.Calendar arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTime(arg0, arg1);
       }
   
  -    public java.sql.Time getTime(String arg0) throws java.sql.SQLException {
  +    public Time getTime(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTime(arg0);
       }
   
  -    public java.sql.Time getTime(String arg0, java.util.Calendar arg1) throws 
java.sql.SQLException {
  +    public Time getTime(String arg0, java.util.Calendar arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTime(arg0, arg1);
       }
   
  -    public java.sql.Timestamp getTimestamp(int arg0) throws java.sql.SQLException {
  +    public Timestamp getTimestamp(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTimestamp(arg0);
       }
   
  -    public java.sql.Timestamp getTimestamp(int arg0, java.util.Calendar arg1) 
throws java.sql.SQLException {
  +    public Timestamp getTimestamp(int arg0, java.util.Calendar arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTimestamp(arg0, arg1);
       }
   
  -    public java.sql.Timestamp getTimestamp(String arg0) throws 
java.sql.SQLException {
  +    public Timestamp getTimestamp(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTimestamp(arg0);
       }
   
  -    public java.sql.Timestamp getTimestamp(String arg0, java.util.Calendar arg1) 
throws java.sql.SQLException {
  +    public Timestamp getTimestamp(String arg0, java.util.Calendar arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getTimestamp(arg0, arg1);
       }
   
  -    public int getType() throws java.sql.SQLException {
  +    public int getType() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getType();
       }
   
  -    public java.io.InputStream getUnicodeStream(int arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getUnicodeStream(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getUnicodeStream(arg0);
       }
   
  -    public java.io.InputStream getUnicodeStream(String arg0) throws 
java.sql.SQLException {
  +    public java.io.InputStream getUnicodeStream(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getUnicodeStream(arg0);
       }
   
  -    public java.sql.SQLWarning getWarnings() throws java.sql.SQLException {
  +    public SQLWarning getWarnings() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.getWarnings();
       }
   
  -    public void insertRow() throws java.sql.SQLException {
  +    public void insertRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.insertRow();
       }
   
  -    public boolean isAfterLast() throws java.sql.SQLException {
  +    public boolean isAfterLast() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.isAfterLast();
       }
   
  -    public boolean isBeforeFirst() throws java.sql.SQLException {
  +    public boolean isBeforeFirst() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.isBeforeFirst();
       }
   
  -    public boolean isFirst() throws java.sql.SQLException {
  +    public boolean isFirst() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.isFirst();
       }
   
  -    public boolean isLast() throws java.sql.SQLException {
  +    public boolean isLast() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.isLast();
       }
   
  -    public boolean last() throws java.sql.SQLException {
  +    public boolean last() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.last();
       }
   
  -    public void moveToCurrentRow() throws java.sql.SQLException {
  +    public void moveToCurrentRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.moveToCurrentRow();
       }
   
  -    public void moveToInsertRow() throws java.sql.SQLException {
  +    public void moveToInsertRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.moveToInsertRow();
       }
   
  -    public boolean next() throws java.sql.SQLException {
  +    public boolean next() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.next();
       }
   
  -    public boolean previous() throws java.sql.SQLException {
  +    public boolean previous() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.previous();
       }
   
  -    public void refreshRow() throws java.sql.SQLException {
  +    public void refreshRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.refreshRow();
       }
   
  -    public boolean relative(int arg0) throws java.sql.SQLException {
  +    public boolean relative(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           return impl.relative(arg0);
       }
   
  -    public boolean rowDeleted() throws java.sql.SQLException {
  +    public boolean rowDeleted() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.rowDeleted();
       }
   
  -    public boolean rowInserted() throws java.sql.SQLException {
  +    public boolean rowInserted() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.rowInserted();
       }
   
  -    public boolean rowUpdated() throws java.sql.SQLException {
  +    public boolean rowUpdated() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.rowUpdated();
       }
   
  -    public void setFetchDirection(int arg0) throws java.sql.SQLException {
  +    public void setFetchDirection(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.setFetchDirection(arg0);
       }
   
  -    public void setFetchSize(int arg0) throws java.sql.SQLException {
  +    public void setFetchSize(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.setFetchSize(arg0);
       }
   
  -    public void updateAsciiStream(int arg0, java.io.InputStream arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateAsciiStream(int arg0, java.io.InputStream arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateAsciiStream(arg0, arg1, arg2);
       }
   
  -    public void updateAsciiStream(String arg0, java.io.InputStream arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateAsciiStream(String arg0, java.io.InputStream arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateAsciiStream(arg0, arg1, arg2);
       }
   
  -    public void updateBigDecimal(int arg0, java.math.BigDecimal arg1) throws 
java.sql.SQLException {
  +    public void updateBigDecimal(int arg0, java.math.BigDecimal arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBigDecimal(arg0, arg1);
       }
   
  -    public void updateBigDecimal(String arg0, java.math.BigDecimal arg1) throws 
java.sql.SQLException {
  +    public void updateBigDecimal(String arg0, java.math.BigDecimal arg1) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBigDecimal(arg0, arg1);
       }
   
  -    public void updateBinaryStream(int arg0, java.io.InputStream arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateBinaryStream(int arg0, java.io.InputStream arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBinaryStream(arg0, arg1, arg2);
       }
   
  -    public void updateBinaryStream(String arg0, java.io.InputStream arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateBinaryStream(String arg0, java.io.InputStream arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBinaryStream(arg0, arg1, arg2);
       }
   
  -    public void updateBoolean(int arg0, boolean arg1) throws java.sql.SQLException {
  +    public void updateBoolean(int arg0, boolean arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBoolean(arg0, arg1);
       }
   
  -    public void updateBoolean(String arg0, boolean arg1) throws 
java.sql.SQLException {
  +    public void updateBoolean(String arg0, boolean arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBoolean(arg0, arg1);
       }
   
  -    public void updateByte(int arg0, byte arg1) throws java.sql.SQLException {
  +    public void updateByte(int arg0, byte arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateByte(arg0, arg1);
       }
   
  -    public void updateByte(String arg0, byte arg1) throws java.sql.SQLException {
  +    public void updateByte(String arg0, byte arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateByte(arg0, arg1);
       }
   
  -    public void updateBytes(int arg0, byte[] arg1) throws java.sql.SQLException {
  +    public void updateBytes(int arg0, byte[] arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBytes(arg0, arg1);
       }
   
  -    public void updateBytes(String arg0, byte[] arg1) throws java.sql.SQLException {
  +    public void updateBytes(String arg0, byte[] arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateBytes(arg0, arg1);
       }
   
  -    public void updateCharacterStream(int arg0, java.io.Reader arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateCharacterStream(int arg0, java.io.Reader arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateCharacterStream(arg0, arg1, arg2);
       }
   
  -    public void updateCharacterStream(String arg0, java.io.Reader arg1, int arg2) 
throws java.sql.SQLException {
  +    public void updateCharacterStream(String arg0, java.io.Reader arg1, int arg2) 
throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateCharacterStream(arg0, arg1, arg2);
       }
   
  -    public void updateDate(int arg0, java.sql.Date arg1) throws 
java.sql.SQLException {
  +    public void updateDate(int arg0, Date arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateDate(arg0, arg1);
       }
   
  -    public void updateDate(String arg0, java.sql.Date arg1) throws 
java.sql.SQLException {
  +    public void updateDate(String arg0, Date arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateDate(arg0, arg1);
       }
   
  -    public void updateDouble(int arg0, double arg1) throws java.sql.SQLException {
  +    public void updateDouble(int arg0, double arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateDouble(arg0, arg1);
       }
   
  -    public void updateDouble(String arg0, double arg1) throws java.sql.SQLException 
{
  +    public void updateDouble(String arg0, double arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateDouble(arg0, arg1);
       }
   
  -    public void updateFloat(int arg0, float arg1) throws java.sql.SQLException {
  +    public void updateFloat(int arg0, float arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateFloat(arg0, arg1);
       }
   
  -    public void updateFloat(String arg0, float arg1) throws java.sql.SQLException {
  +    public void updateFloat(String arg0, float arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateFloat(arg0, arg1);
       }
   
  -    public void updateInt(int arg0, int arg1) throws java.sql.SQLException {
  +    public void updateInt(int arg0, int arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateInt(arg0, arg1);
       }
   
  -    public void updateInt(String arg0, int arg1) throws java.sql.SQLException {
  +    public void updateInt(String arg0, int arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateInt(arg0, arg1);
       }
   
  -    public void updateLong(int arg0, long arg1) throws java.sql.SQLException {
  +    public void updateLong(int arg0, long arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateLong(arg0, arg1);
       }
   
  -    public void updateLong(String arg0, long arg1) throws java.sql.SQLException {
  +    public void updateLong(String arg0, long arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateLong(arg0, arg1);
       }
   
  -    public void updateNull(int arg0) throws java.sql.SQLException {
  +    public void updateNull(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateNull(arg0);
       }
   
  -    public void updateNull(String arg0) throws java.sql.SQLException {
  +    public void updateNull(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateNull(arg0);
       }
   
  -    public void updateObject(int arg0, Object arg1) throws java.sql.SQLException {
  +    public void updateObject(int arg0, Object arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateObject(arg0, arg1);
       }
   
  -    public void updateObject(int arg0, Object arg1, int arg2) throws 
java.sql.SQLException {
  +    public void updateObject(int arg0, Object arg1, int arg2) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateObject(arg0, arg1, arg2);
       }
   
  -    public void updateObject(String arg0, Object arg1) throws java.sql.SQLException 
{
  +    public void updateObject(String arg0, Object arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateObject(arg0, arg1);
       }
   
  -    public void updateObject(String arg0, Object arg1, int arg2) throws 
java.sql.SQLException {
  +    public void updateObject(String arg0, Object arg1, int arg2) throws 
SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateObject(arg0, arg1, arg2);
       }
   
  -    public void updateRow() throws java.sql.SQLException {
  +    public void updateRow() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           setLastUsed();
           impl.updateRow();
       }
   
  -    public void updateShort(int arg0, short arg1) throws java.sql.SQLException {
  +    public void updateShort(int arg0, short arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateShort(arg0, arg1);
       }
   
  -    public void updateShort(String arg0, short arg1) throws java.sql.SQLException {
  +    public void updateShort(String arg0, short arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateShort(arg0, arg1);
       }
   
  -    public void updateString(int arg0, String arg1) throws java.sql.SQLException {
  +    public void updateString(int arg0, String arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateString(arg0, arg1);
       }
   
  -    public void updateString(String arg0, String arg1) throws java.sql.SQLException 
{
  +    public void updateString(String arg0, String arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateString(arg0, arg1);
       }
   
  -    public void updateTime(int arg0, java.sql.Time arg1) throws 
java.sql.SQLException {
  +    public void updateTime(int arg0, Time arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateTime(arg0, arg1);
       }
   
  -    public void updateTime(String arg0, java.sql.Time arg1) throws 
java.sql.SQLException {
  +    public void updateTime(String arg0, Time arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateTime(arg0, arg1);
       }
   
  -    public void updateTimestamp(int arg0, java.sql.Timestamp arg1) throws 
java.sql.SQLException {
  +    public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateTimestamp(arg0, arg1);
       }
   
  -    public void updateTimestamp(String arg0, java.sql.Timestamp arg1) throws 
java.sql.SQLException {
  +    public void updateTimestamp(String arg0, Timestamp arg1) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           impl.updateTimestamp(arg0, arg1);
       }
   
  -    public boolean wasNull() throws java.sql.SQLException {
  +    public boolean wasNull() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return impl.wasNull();
       }
   
  -    // ---- End Implementation of java.sql.ResultSet ----
  +    // ---- End Implementation of ResultSet ----
   }
  
  
  
  1.2       +40 -31    jboss/src/main/org/jboss/minerva/jdbc/StatementInPool.java
  
  Index: StatementInPool.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/jdbc/StatementInPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StatementInPool.java      2000/06/02 13:48:44     1.1
  +++ StatementInPool.java      2000/08/30 16:17:05     1.2
  @@ -6,13 +6,18 @@
    */
   package org.jboss.minerva.jdbc;
   
  -import java.sql.*;
  +import java.sql.Connection;
  +import java.sql.ResultSet;
  +import java.sql.Statement;
  +import java.sql.SQLException;
  +import java.sql.SQLWarning;
   
  +
   /**
    * Wraps a Statement to track errors and the last used time for the owning
    * connection. That time is updated every time a SQL action is performed
    * (executeQuery, executeUpdate, etc.).
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class StatementInPool implements Statement {
  @@ -57,7 +62,7 @@
   
       // ---- Implementation of java.sql.Statement ----
   
  -    public void addBatch(String arg0) throws java.sql.SQLException {
  +    public void addBatch(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.addBatch(arg0);
  @@ -67,7 +72,7 @@
           }
       }
   
  -    public void cancel() throws java.sql.SQLException {
  +    public void cancel() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.cancel();
  @@ -77,7 +82,7 @@
           }
       }
   
  -    public void clearBatch() throws java.sql.SQLException {
  +    public void clearBatch() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.clearBatch();
  @@ -87,7 +92,7 @@
           }
       }
   
  -    public void clearWarnings() throws java.sql.SQLException {
  +    public void clearWarnings() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.clearWarnings();
  @@ -97,16 +102,20 @@
           }
       }
   
  -    public void close() throws java.sql.SQLException {
  +    public void close() throws SQLException {
           if(impl != null) {
               impl.close();
               con.statementClosed(this);
           }
  +        clearFields();
  +    }
  +
  +    protected void clearFields() {
           con = null;
           impl = null;
       }
   
  -    public boolean execute(String arg0) throws java.sql.SQLException {
  +    public boolean execute(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               setLastUsed();
  @@ -117,7 +126,7 @@
           }
       }
   
  -    public int[] executeBatch() throws java.sql.SQLException {
  +    public int[] executeBatch() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               setLastUsed();
  @@ -128,7 +137,7 @@
           }
       }
   
  -    public ResultSet executeQuery(String arg0) throws java.sql.SQLException {
  +    public ResultSet executeQuery(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               setLastUsed();
  @@ -139,7 +148,7 @@
           }
       }
   
  -    public int executeUpdate(String arg0) throws java.sql.SQLException {
  +    public int executeUpdate(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               setLastUsed();
  @@ -150,12 +159,12 @@
           }
       }
   
  -    public Connection getConnection() throws java.sql.SQLException {
  +    public Connection getConnection() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           return con;
       }
   
  -    public int getFetchDirection() throws java.sql.SQLException {
  +    public int getFetchDirection() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getFetchDirection();
  @@ -165,7 +174,7 @@
           }
       }
   
  -    public int getFetchSize() throws java.sql.SQLException {
  +    public int getFetchSize() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getFetchSize();
  @@ -175,7 +184,7 @@
           }
       }
   
  -    public int getMaxFieldSize() throws java.sql.SQLException {
  +    public int getMaxFieldSize() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getMaxFieldSize();
  @@ -185,7 +194,7 @@
           }
       }
   
  -    public int getMaxRows() throws java.sql.SQLException {
  +    public int getMaxRows() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getMaxRows();
  @@ -195,7 +204,7 @@
           }
       }
   
  -    public boolean getMoreResults() throws java.sql.SQLException {
  +    public boolean getMoreResults() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getMoreResults();
  @@ -205,7 +214,7 @@
           }
       }
   
  -    public int getQueryTimeout() throws java.sql.SQLException {
  +    public int getQueryTimeout() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getQueryTimeout();
  @@ -215,7 +224,7 @@
           }
       }
   
  -    public ResultSet getResultSet() throws java.sql.SQLException {
  +    public ResultSet getResultSet() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return new ResultSetInPool(impl.getResultSet(), this);
  @@ -225,7 +234,7 @@
           }
       }
   
  -    public int getResultSetConcurrency() throws java.sql.SQLException {
  +    public int getResultSetConcurrency() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getResultSetConcurrency();
  @@ -235,7 +244,7 @@
           }
       }
   
  -    public int getResultSetType() throws java.sql.SQLException {
  +    public int getResultSetType() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getResultSetType();
  @@ -245,7 +254,7 @@
           }
       }
   
  -    public int getUpdateCount() throws java.sql.SQLException {
  +    public int getUpdateCount() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getUpdateCount();
  @@ -255,7 +264,7 @@
           }
       }
   
  -    public java.sql.SQLWarning getWarnings() throws java.sql.SQLException {
  +    public SQLWarning getWarnings() throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               return impl.getWarnings();
  @@ -265,7 +274,7 @@
           }
       }
   
  -    public void setCursorName(String arg0) throws java.sql.SQLException {
  +    public void setCursorName(String arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setCursorName(arg0);
  @@ -275,7 +284,7 @@
           }
       }
   
  -    public void setEscapeProcessing(boolean arg0) throws java.sql.SQLException {
  +    public void setEscapeProcessing(boolean arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setEscapeProcessing(arg0);
  @@ -285,7 +294,7 @@
           }
       }
   
  -    public void setFetchDirection(int arg0) throws java.sql.SQLException {
  +    public void setFetchDirection(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setFetchDirection(arg0);
  @@ -295,7 +304,7 @@
           }
       }
   
  -    public void setFetchSize(int arg0) throws java.sql.SQLException {
  +    public void setFetchSize(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setFetchSize(arg0);
  @@ -305,7 +314,7 @@
           }
       }
   
  -    public void setMaxFieldSize(int arg0) throws java.sql.SQLException {
  +    public void setMaxFieldSize(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setMaxFieldSize(arg0);
  @@ -315,7 +324,7 @@
           }
       }
   
  -    public void setMaxRows(int arg0) throws java.sql.SQLException {
  +    public void setMaxRows(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setMaxRows(arg0);
  @@ -325,7 +334,7 @@
           }
       }
   
  -    public void setQueryTimeout(int arg0) throws java.sql.SQLException {
  +    public void setQueryTimeout(int arg0) throws SQLException {
           if(impl == null) throw new SQLException(CLOSED);
           try {
               impl.setQueryTimeout(arg0);
  @@ -335,5 +344,5 @@
           }
       }
   
  -    // ---- End Implementation of java.sql.Statement ----
  +    // ---- End Implementation of Statement ----
   }
  
  
  
  1.1                  jboss/src/main/org/jboss/minerva/jdbc/PSCacheKey.java
  
  Index: PSCacheKey.java
  ===================================================================
  package org.jboss.minerva.jdbc;
  
  import java.sql.Connection;
  
  public class PSCacheKey {
      public Connection con;
      public String sql;
  
      public PSCacheKey(Connection con, String sql) {
          this.con = con;
          this.sql = sql;
      }
  
      public boolean equals(Object o) {
          PSCacheKey key = (PSCacheKey)o;
          return key.con.equals(con) && key.sql.equals(sql);
      }
  
      public int hashCode() {
          return con.hashCode() ^ sql.hashCode();
      }
  }
  
  
  

Reply via email to