com.p6spy.engine.spy
Class P6ProxyConnection

java.lang.Object
  extended bycom.p6spy.engine.spy.P6ProxyConnection
All Implemented Interfaces:
Connection

public class P6ProxyConnection
extends Object
implements Connection

This class proxies for a real connection in support of pooled connections. Instances are created by calling P6PooledConnection.getConnection, which is done by P6PooledConnectionDataSource. Each instance is uniquely associated with the PooledConnection that created it, and with the real JDBC Connection that is associated with that object. After instantiation objects of this class are valid until the close method is called. This method does not close the read connection, rather it generates and delivers a ConnectionEvent message of type close by calling the PooledConnection object. This lets the ultimate user of these classes (probably an EJB Container) know that the PooledConnection is avaiable for a new assignment.

See Also:
PooledConnection, ConnectionPoolDataSource, P6PooledConnection, P6ConnectionPoolDataSource

Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
P6ProxyConnection(P6PooledConnection pooledConnection, Connection realConnection)
          Take the given real connection and construct a proxy connection to represent it.
 
Method Summary
 void clearWarnings()
          Pass through to P6 wrapper connection.
 void close()
          Dissassociate this instance from the real connection, and notify any concerned parties that the client is done with the associated pooled connection, so that it may be returned to the pool.
 void commit()
          Pass through to P6 wrapper connection.
 Statement createStatement()
          Pass through to P6 wrapper connection.
 Statement createStatement(int resultSetType, int resultSetConcurrency)
          Pass through to P6 wrapper connection.
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Pass through to P6 wrapper connection.
 boolean getAutoCommit()
          Pass through to P6 wrapper connection.
 String getCatalog()
          Pass through to P6 wrapper connection.
 int getHoldability()
          Pass through to P6 wrapper connection.
 DatabaseMetaData getMetaData()
          Pass through to P6 wrapper connection.
 int getTransactionIsolation()
          Pass through to P6 wrapper connection.
 Map getTypeMap()
          Pass through to P6 wrapper connection.
 SQLWarning getWarnings()
          Pass through to P6 wrapper connection.
 boolean isClosed()
          Pass through to P6 wrapper connection.
 boolean isReadOnly()
          Pass through to P6 wrapper connection.
 String nativeSQL(String sql)
          Pass through to P6 wrapper connection.
 CallableStatement prepareCall(String sql)
          Pass through to P6 wrapper connection.
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
          Pass through to P6 wrapper connection.
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Pass through to P6 wrapper connection.
 PreparedStatement prepareStatement(String sql, String[] columnNames)
          Pass through to P6 wrapper connection.
 void releaseSavepoint(Savepoint savepoint)
          Pass through to P6 wrapper connection.
 void rollback()
          Pass through to P6 wrapper connection.
 void rollback(Savepoint savepoint)
          Pass through to P6 wrapper connection.
 void setAutoCommit(boolean autoCommit)
          Pass through to P6 wrapper connection.
 void setCatalog(String catalog)
          Pass through to P6 wrapper connection.
 void setHoldability(int holdability)
          Pass through to P6 wrapper connection.
 void setReadOnly(boolean readOnly)
          Pass through to P6 wrapper connection.
 Savepoint setSavepoint()
          Pass through to P6 wrapper connection.
 Savepoint setSavepoint(String name)
          Pass through to P6 wrapper connection.
 void setTransactionIsolation(int level)
          Pass through to P6 wrapper connection.
 void setTypeMap(Map map)
          Pass through to P6 wrapper connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P6ProxyConnection

public P6ProxyConnection(P6PooledConnection pooledConnection,
                         Connection realConnection)
                  throws SQLException
Take the given real connection and construct a proxy connection to represent it. Associate the proxy with the PooledConnection instance that "owns" it.

Parameters:
pooledConnection - reference to pooledConnection that instantiated this object
realConnection - P6Spy wrapper connection for real connection to db
Throws:
SQLException
Method Detail

close

public void close()
           throws SQLException
Dissassociate this instance from the real connection, and notify any concerned parties that the client is done with the associated pooled connection, so that it may be returned to the pool. The state of the real connection is not affected by this method.

Specified by:
close in interface Connection
Throws:
SQLException

clearWarnings

public void clearWarnings()
                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
clearWarnings in interface Connection
Throws:
SQLException

commit

public void commit()
            throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
commit in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement()
                          throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
createStatement in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency)
                          throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
createStatement in interface Connection
Throws:
SQLException

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getAutoCommit in interface Connection
Throws:
SQLException

getCatalog

public String getCatalog()
                  throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getCatalog in interface Connection
Throws:
SQLException

getMetaData

public DatabaseMetaData getMetaData()
                             throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getMetaData in interface Connection
Throws:
SQLException

getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getTransactionIsolation in interface Connection
Throws:
SQLException

getTypeMap

public Map getTypeMap()
               throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getTypeMap in interface Connection
Throws:
SQLException

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getWarnings in interface Connection
Throws:
SQLException

isReadOnly

public boolean isReadOnly()
                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
isReadOnly in interface Connection
Throws:
SQLException

nativeSQL

public String nativeSQL(String sql)
                 throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
nativeSQL in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

rollback

public void rollback()
              throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
rollback in interface Connection
Throws:
SQLException

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setAutoCommit in interface Connection
Throws:
SQLException

setCatalog

public void setCatalog(String catalog)
                throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setCatalog in interface Connection
Throws:
SQLException

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setReadOnly in interface Connection
Throws:
SQLException

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setTransactionIsolation in interface Connection
Throws:
SQLException

setTypeMap

public void setTypeMap(Map map)
                throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setTypeMap in interface Connection
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
isClosed in interface Connection
Throws:
SQLException

setHoldability

public void setHoldability(int holdability)
                    throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setHoldability in interface Connection
Throws:
SQLException

getHoldability

public int getHoldability()
                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
getHoldability in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setSavepoint in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
setSavepoint in interface Connection
Throws:
SQLException

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
releaseSavepoint in interface Connection
Throws:
SQLException

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
rollback in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
createStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Pass through to P6 wrapper connection. Catches and re-throws exceptions after delivering ConnectionEvents through P6PooledConnection.deliverEvent.

Specified by:
prepareStatement in interface Connection
Throws:
SQLException