MySQL Connector/J size='-1'>5.0.8

com.mysql.jdbc.jdbc2.optional
Class ConnectionWrapper

java.lang.Object
  extended by com.mysql.jdbc.jdbc2.optional.ConnectionWrapper
All Implemented Interfaces:
java.sql.Connection

public class ConnectionWrapper
extends java.lang.Object
implements java.sql.Connection

This class serves as a wrapper for the org.gjt.mm.mysql.jdbc2.Connection class. It is returned to the application server which may wrap it again and then return it to the application client in response to dataSource.getConnection().

All method invocations are forwarded to org.gjt.mm.mysql.jdbc2.Connection unless the close method was previously called, in which case a sqlException is thrown. The close method performs a 'logical close' on the connection.

All sqlExceptions thrown by the physical connection are intercepted and sent to connectionEvent listeners before being thrown to client.

Author:
Todd Wolff todd.wolff_at_prodigy.net
See Also:
org.gjt.mm.mysql.jdbc2.Connection, org.gjt.mm.mysql.jdbc2.optional.MysqlPooledConnection

Field Summary
protected  MysqlPooledConnection pooledConnection
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection, Connection mysqlConnection, boolean forXa)
          Construct a new LogicalHandle and set instance variables
 
Method Summary
protected  void checkAndFireConnectionError(java.sql.SQLException sqlEx)
          Fires connection error event if required, before re-throwing exception
 void clearWarnings()
          Passes call to method on physical connection instance.
 java.sql.PreparedStatement clientPrepare(java.lang.String sql)
           
 java.sql.PreparedStatement clientPrepare(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 void close()
          The physical connection is not actually closed.
protected  void close(boolean fireClosedEvent)
           
 void commit()
          Passes call to method on physical connection instance.
 java.sql.Statement createStatement()
          Passes call to method on physical connection instance.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Passes call to method on physical connection instance.
 java.sql.Statement createStatement(int arg0, int arg1, int arg2)
           
 boolean getAutoCommit()
          Passes call to method on physical connection instance.
 java.lang.String getCatalog()
          Passes call to method on physical connection instance.
 int getHoldability()
           
 long getIdleFor()
          Allows clients to determine how long this connection has been idle.
 java.sql.DatabaseMetaData getMetaData()
          Passes call to method on physical connection instance.
 int getTransactionIsolation()
          Passes call to method on physical connection instance.
 java.util.Map getTypeMap()
          Passes call to method on physical connection instance.
 java.sql.SQLWarning getWarnings()
          Passes call to method on physical connection instance.
 boolean isClosed()
          Passes call to method on physical connection instance.
protected  boolean isInGlobalTx()
           
 boolean isMasterConnection()
           
 boolean isReadOnly()
          Passes call to method on physical connection instance.
 boolean isSameResource(java.sql.Connection c)
           
 java.lang.String nativeSQL(java.lang.String sql)
          Passes call to method on physical connection instance.
 void ping()
           
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Passes call to method on physical connection instance.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Passes call to method on physical connection instance.
 java.sql.CallableStatement prepareCall(java.lang.String arg0, int arg1, int arg2, int arg3)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Passes call to method on physical connection instance.
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int arg1)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int[] arg1)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Passes call to method on physical connection instance.
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, int arg1, int arg2, int arg3)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, java.lang.String[] arg1)
           
 void releaseSavepoint(java.sql.Savepoint arg0)
           
 void rollback()
          Passes call to method on physical connection instance.
 void rollback(java.sql.Savepoint arg0)
           
 void setAutoCommit(boolean autoCommit)
          Passes call to method on physical connection instance.
 void setCatalog(java.lang.String catalog)
          Passes call to method on physical connection instance.
 void setHoldability(int arg0)
           
protected  void setInGlobalTx(boolean flag)
           
 void setReadOnly(boolean readOnly)
          Passes call to method on physical connection instance.
 java.sql.Savepoint setSavepoint()
           
 java.sql.Savepoint setSavepoint(java.lang.String arg0)
           
 void setTransactionIsolation(int level)
          Passes call to method on physical connection instance.
 void setTypeMap(java.util.Map map)
          Passes call to method on physical connection instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pooledConnection

protected MysqlPooledConnection pooledConnection
Constructor Detail

ConnectionWrapper

public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection,
                         Connection mysqlConnection,
                         boolean forXa)
                  throws java.sql.SQLException
Construct a new LogicalHandle and set instance variables

Parameters:
mysqlPooledConnection - reference to object that instantiated this object
mysqlConnection - physical connection to db
Throws:
java.sql.SQLException - if an error occurs.
Method Detail

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
setAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.setAutoCommit(boolean)

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.getAutoCommit()

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#setCatalog()

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getCatalog in interface java.sql.Connection
Returns:
the current catalog
Throws:
java.sql.SQLException - if an error occurs

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
isClosed in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.isClosed()

isMasterConnection

public boolean isMasterConnection()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

setHoldability

public void setHoldability(int arg0)
                    throws java.sql.SQLException
Specified by:
setHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.setHoldability(int)

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Specified by:
getHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.getHoldability()

getIdleFor

public long getIdleFor()
Allows clients to determine how long this connection has been idle.

Returns:
how long the connection has been idle.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
a metadata instance
Throws:
java.sql.SQLException - if an error occurs

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
setReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#setReadOnly()

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
isReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.isReadOnly()

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.setSavepoint()

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String arg0)
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.setSavepoint(String)

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
setTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#setTransactionIsolation()

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.getTransactionIsolation()

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#setTypeMap()

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.getTypeMap()

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
getWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.getWarnings()

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - if an error occurs

close

public void close()
           throws java.sql.SQLException
The physical connection is not actually closed. the physical connection is closed when the application server calls mysqlPooledConnection.close(). this object is de-referenced by the pooled connection each time mysqlPooledConnection.getConnection() is called by app server.

Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException - if an error occurs

commit

public void commit()
            throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - if an error occurs

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.createStatement()

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.createStatement()

createStatement

public java.sql.Statement createStatement(int arg0,
                                          int arg1,
                                          int arg2)
                                   throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.createStatement(int, int, int)

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
nativeSQL in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#nativeSQL()

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#prepareCall()

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#prepareCall()

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String arg0,
                                              int arg1,
                                              int arg2,
                                              int arg3)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.prepareCall(String, int, int, int)

clientPrepare

public java.sql.PreparedStatement clientPrepare(java.lang.String sql)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

clientPrepare

public java.sql.PreparedStatement clientPrepare(java.lang.String sql,
                                                int resultSetType,
                                                int resultSetConcurrency)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#prepareStatement()

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
java.sql.Connection#prepareStatement()

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int arg1,
                                                   int arg2,
                                                   int arg3)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.prepareStatement(String, int, int, int)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.prepareStatement(String, int)

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int[] arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.prepareStatement(String, int[])

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   java.lang.String[] arg1)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.prepareStatement(String, String[])

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint arg0)
                      throws java.sql.SQLException
Specified by:
releaseSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.releaseSavepoint(Savepoint)

rollback

public void rollback()
              throws java.sql.SQLException
Passes call to method on physical connection instance. Notifies listeners of any caught exceptions before re-throwing to client.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.rollback()

rollback

public void rollback(java.sql.Savepoint arg0)
              throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException
See Also:
Connection.rollback(Savepoint)

isSameResource

public boolean isSameResource(java.sql.Connection c)

close

protected void close(boolean fireClosedEvent)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

isInGlobalTx

protected boolean isInGlobalTx()

setInGlobalTx

protected void setInGlobalTx(boolean flag)

ping

public void ping()
          throws java.sql.SQLException
Throws:
java.sql.SQLException

checkAndFireConnectionError

protected void checkAndFireConnectionError(java.sql.SQLException sqlEx)
                                    throws java.sql.SQLException
Fires connection error event if required, before re-throwing exception

Parameters:
sqlEx - the SQLException that has ocurred
Throws:
java.sql.SQLException - (rethrown)

MySQL Connector/J size='-1'>5.0.8