Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mysql.jdbc.jdbc2.optional
Class ConnectionWrapper  view ConnectionWrapper download ConnectionWrapper.java

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

class ConnectionWrapper
extends WrapperBase
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.


Field Summary
private  boolean closed
           
private  java.lang.String invalidHandleStr
           
private  java.sql.Connection mc
           
private  MysqlPooledConnection mpc
           
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, java.sql.Connection mysqlConnection)
          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.
 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)
          This method creates a new SQL statement with the specified type, concurrency and holdability, instead of using the defaults.
 boolean getAutoCommit()
          Passes call to method on physical connection instance.
 java.lang.String getCatalog()
          Passes call to method on physical connection instance.
 int getHoldability()
          Gets the default holdability of ResultSetS that are created from StatementS using this Connection.
 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.
 boolean isReadOnly()
          Passes call to method on physical connection instance.
 java.lang.String nativeSQL(java.lang.String sql)
          Passes call to method on physical connection instance.
 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)
          This method creates a new CallableStatement for the specified SQL string.
 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)
          This method creates a new PreparedStatement for the specified SQL string.
 java.sql.PreparedStatement prepareStatement(java.lang.String arg0, java.lang.String[] arg1)
           
 void releaseSavepoint(java.sql.Savepoint arg0)
          Removes the specified savepoint from this Connection.
 void rollback()
          Passes call to method on physical connection instance.
 void rollback(java.sql.Savepoint arg0)
          Undoes all changes made after the specified savepoint was set.
 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)
          Sets the default holdability of ResultSetS that are created from StatementS using this Connection.
 void setReadOnly(boolean readOnly)
          Passes call to method on physical connection instance.
 java.sql.Savepoint setSavepoint()
          Creates a new unnamed savepoint for this Connection
 java.sql.Savepoint setSavepoint(java.lang.String arg0)
          Creates a new savepoint with the specifiend name for this Connection.
 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

mc

private java.sql.Connection mc

mpc

private MysqlPooledConnection mpc

invalidHandleStr

private java.lang.String invalidHandleStr

closed

private boolean closed

pooledConnection

protected MysqlPooledConnection pooledConnection
Constructor Detail

ConnectionWrapper

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

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

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

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

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

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

setHoldability

public void setHoldability(int arg0)
                    throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Sets the default holdability of ResultSetS that are created from StatementS using this Connection.

Specified by:
setHoldability in interface java.sql.Connection

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Gets the default holdability of ResultSetS that are created from StatementS using this Connection.

Specified by:
getHoldability in interface java.sql.Connection

getIdleFor

public long getIdleFor()
Allows clients to determine how long this 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

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

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

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Creates a new unnamed savepoint for this Connection

Specified by:
setSavepoint in interface java.sql.Connection

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String arg0)
                                throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Creates a new savepoint with the specifiend name for this Connection.

Specified by:
setSavepoint in interface java.sql.Connection

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

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

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

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

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

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

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

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

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

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

createStatement

public java.sql.Statement createStatement(int arg0,
                                          int arg1,
                                          int arg2)
                                   throws java.sql.SQLException
Description copied from interface: java.sql.Connection
This method creates a new SQL statement with the specified type, concurrency and holdability, instead of using the defaults. Valid values for these parameters are specified in the ResultSet class.

Specified by:
createStatement in interface java.sql.Connection

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

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

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

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String arg0,
                                              int arg1,
                                              int arg2,
                                              int arg3)
                                       throws java.sql.SQLException
Description copied from interface: java.sql.Connection
This method creates a new CallableStatement for the specified SQL string. Thie method is designed to be used with stored procedures. The specified result set type, concurrency and holdability will be used. Valid values for these parameters are specified in the ResultSet class.

Specified by:
prepareCall in interface java.sql.Connection

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

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String arg0,
                                                   int arg1,
                                                   int arg2,
                                                   int arg3)
                                            throws java.sql.SQLException
Description copied from interface: java.sql.Connection
This method creates a new PreparedStatement for the specified SQL string. This method is designed for use with parameterized statements. The specified result set type, concurrency and holdability will be used. Valid values for these parameters are specified in the ResultSet class.

Specified by:
prepareStatement in interface java.sql.Connection

prepareStatement

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

prepareStatement

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

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

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint arg0)
                      throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Removes the specified savepoint from this Connection. Refering to a savepoint after it was removed is an error and will throw an SQLException.

Specified by:
releaseSavepoint in interface java.sql.Connection

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

rollback

public void rollback(java.sql.Savepoint arg0)
              throws java.sql.SQLException
Description copied from interface: java.sql.Connection
Undoes all changes made after the specified savepoint was set.

Specified by:
rollback in interface java.sql.Connection

close

protected void close(boolean fireClosedEvent)
              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