Package net.sourceforge.jtds.jdbcx.proxy
Class ConnectionProxy
- java.lang.Object
-
- net.sourceforge.jtds.jdbcx.proxy.ConnectionProxy
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
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
Fields Modifier and Type Field Description private boolean
_closed
private ConnectionJDBC2
_connection
private PooledConnection
_pooledConnection
-
Constructor Summary
Constructors Constructor Description ConnectionProxy(PooledConnection pooledConnection, java.sql.Connection connection)
Constructs a new connection proxy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(java.util.concurrent.Executor executor)
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.Array
createArrayOf(java.lang.String typeName, java.lang.Object[] elements)
java.sql.Blob
createBlob()
java.sql.Clob
createClob()
java.sql.NClob
createNClob()
java.sql.SQLXML
createSQLXML()
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.java.sql.Struct
createStruct(java.lang.String typeName, java.lang.Object[] attributes)
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.java.util.Properties
getClientInfo()
java.lang.String
getClientInfo(java.lang.String name)
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
getNetworkTimeout()
java.lang.String
getSchema()
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.boolean
isValid(int timeout)
boolean
isWrapperFor(java.lang.Class arg0)
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
setClientInfo(java.lang.String name, java.lang.String value)
void
setClientInfo(java.util.Properties properties)
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
setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)
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
setSchema(java.lang.String schema)
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.java.lang.Object
unwrap(java.lang.Class arg0)
private void
validateConnection()
Validates the connection state.
-
-
-
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 interfacejava.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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.- Overrides:
finalize
in classjava.lang.Object
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException
- Specified by:
createArrayOf
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException
- Specified by:
createBlob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException
- Specified by:
createClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException
- Specified by:
createNClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException
- Specified by:
createSQLXML
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException
- Specified by:
createStruct
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException
- Specified by:
isValid
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class arg0) throws java.sql.SQLException
- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
unwrap
public java.lang.Object unwrap(java.lang.Class arg0) throws java.sql.SQLException
- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException
- Specified by:
setSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException
- Specified by:
getSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
- Specified by:
abort
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException
- Specified by:
setNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException
- Specified by:
getNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
-