net.sourceforge.jtds.jdbcx.proxy
Class ConnectionProxy

java.lang.Object
  extended bynet.sourceforge.jtds.jdbcx.proxy.ConnectionProxy
All Implemented Interfaces:
java.sql.Connection

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

This class would be better implemented as a java.lang.reflect.Proxy. However, this feature was not added until 1.3 and reflection performance was not improved until 1.4. Since the driver still needs to be compatible with 1.2 and 1.3 this class is used to delegate the calls to the connection with minimal overhead.

Version:
$Id: ConnectionProxy.java,v 1.7.2.3 2009-12-30 08:45:34 ickzon Exp $

Field Summary
private  boolean _closed
           
private  ConnectionJDBC2 _connection
           
private  PooledConnection _pooledConnection
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
ConnectionProxy(PooledConnection pooledConnection, java.sql.Connection connection)
          Constructs a new connection proxy.
 
Method Summary
 void clearWarnings()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void close()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void commit()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.Statement createStatement()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
protected  void finalize()
          Closes the proxy, releasing the connection.
 boolean getAutoCommit()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.lang.String getCatalog()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 int getHoldability()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.DatabaseMetaData getMetaData()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 int getTransactionIsolation()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.util.Map getTypeMap()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.SQLWarning getWarnings()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 boolean isClosed()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 boolean isReadOnly()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.lang.String nativeSQL(java.lang.String sql)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
(package private)  void processSQLException(java.sql.SQLException sqlException)
          Processes SQLExceptions.
 void releaseSavepoint(java.sql.Savepoint savepoint)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void rollback()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void rollback(java.sql.Savepoint savepoint)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setAutoCommit(boolean autoCommit)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setCatalog(java.lang.String catalog)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setHoldability(int holdability)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setReadOnly(boolean readOnly)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.Savepoint setSavepoint()
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 java.sql.Savepoint setSavepoint(java.lang.String name)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setTransactionIsolation(int level)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
 void setTypeMap(java.util.Map map)
          Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.
private  void validateConnection()
          Validates the connection state.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_pooledConnection

private PooledConnection _pooledConnection

_connection

private ConnectionJDBC2 _connection

_closed

private boolean _closed
Constructor Detail

ConnectionProxy

public ConnectionProxy(PooledConnection pooledConnection,
                       java.sql.Connection connection)
Constructs a new connection proxy.

Method Detail

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

close

public void close()
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

Specified by:
close in interface java.sql.Connection

commit

public void commit()
            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency,
                                              int resultSetHoldability)
                                       throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int autoGeneratedKeys)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int[] columnIndexes)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   java.lang.String[] columnNames)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency,
                                                   int resultSetHoldability)
                                            throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

rollback

public void rollback()
              throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

rollback

public void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setHoldability

public void setHoldability(int holdability)
                    throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String name)
                                throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Delgates calls to the connection; SQLExceptions thrown from the connection will cause an event to be fired on the connection pool listeners.

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

validateConnection

private void validateConnection()
                         throws java.sql.SQLException
Validates the connection state.

Throws:
java.sql.SQLException

processSQLException

void processSQLException(java.sql.SQLException sqlException)
                   throws java.sql.SQLException
Processes SQLExceptions.

Throws:
java.sql.SQLException

finalize

protected void finalize()
Closes the proxy, releasing the connection.



Generated on October 27 2012