org.enhydra.jdbc.standard
Class StandardConnectionHandle
java.lang.Object
org.enhydra.jdbc.util.JdbcUtil
org.enhydra.jdbc.core.CoreConnection
org.enhydra.jdbc.standard.StandardConnectionHandle
- All Implemented Interfaces:
- java.sql.Connection
- Direct Known Subclasses:
- InformixConnectionHandle, StandardXAConnectionHandle, SybaseConnectionHandle
- public class StandardConnectionHandle
- extends CoreConnection
This is an implementation of java.sql.Connection which simply
delegates almost everything to an underlying physical implemention
of the same interface.
It relies on a StandardPooledConnection to create it and to supply the
physical connection and a cache of PreparedStatements. This class will
try to re-use PreparedStatements wherever possible and will add to the
cache when totally new PreparedStatements get created.
Fields inherited from class org.enhydra.jdbc.util.JdbcUtil |
log |
Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
Method Summary |
void |
catchInvoke(java.sql.SQLException e)
Exception management : catch or throw the exception |
void |
close()
Closes this StandardConnectionHandle and prevents it
from being reused. |
protected java.sql.PreparedStatement |
createPreparedStatement(java.lang.String sql,
int type,
int concurrency)
|
boolean |
isClosed()
|
void |
preInvoke()
Pre-invokation of the delegation, in case of connection is
closed, we throw an exception |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Creates a PreparedStatement for the given SQL. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Creates a PreparedStatement for the given SQL, type and concurrency. |
protected void |
setupPreparedStatementCache()
|
Methods inherited from class org.enhydra.jdbc.core.CoreConnection |
clearWarnings, commit, createStatement, createStatement, createStatement, getAutoCommit, getCatalog, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
masterPrepStmtCache
protected java.util.Hashtable masterPrepStmtCache
preparedStatementCache
protected LRUCache preparedStatementCache
inUse
public java.util.Hashtable inUse
isReallyUsed
public boolean isReallyUsed
StandardConnectionHandle
public StandardConnectionHandle(StandardPooledConnection pooledCon,
java.util.Hashtable preparedStatementCache,
int preparedStmtCacheSize)
- Constructor.
setupPreparedStatementCache
protected void setupPreparedStatementCache()
preInvoke
public void preInvoke()
throws java.sql.SQLException
- Pre-invokation of the delegation, in case of connection is
closed, we throw an exception
- Specified by:
preInvoke
in class CoreConnection
- Throws:
java.sql.SQLException
catchInvoke
public void catchInvoke(java.sql.SQLException e)
throws java.sql.SQLException
- Exception management : catch or throw the exception
- Specified by:
catchInvoke
in class CoreConnection
- Throws:
java.sql.SQLException
close
public void close()
throws java.sql.SQLException
- Closes this StandardConnectionHandle and prevents it
from being reused. It also returns used PreparedStatements
to the PreparedStatement cache and notifies all listeners.
- Specified by:
close
in interface java.sql.Connection
- Overrides:
close
in class CoreConnection
- Throws:
java.sql.SQLException
createPreparedStatement
protected java.sql.PreparedStatement createPreparedStatement(java.lang.String sql,
int type,
int concurrency)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
- Creates a PreparedStatement for the given SQL. If possible, the
statement is fetched from the cache.
- Specified by:
prepareStatement
in interface java.sql.Connection
- Overrides:
prepareStatement
in class CoreConnection
- Throws:
java.sql.SQLException
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
- Creates a PreparedStatement for the given SQL, type and concurrency.
If possible, the statement is fetched from the cache.
- Specified by:
prepareStatement
in interface java.sql.Connection
- Overrides:
prepareStatement
in class CoreConnection
- Throws:
java.sql.SQLException
isClosed
public boolean isClosed()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
- Throws:
java.sql.SQLException