Save This Page
Home » xapool-1.5.0-src » org.enhydra.jdbc » standard » [javadoc | source]
org.enhydra.jdbc.standard
public class: StandardConnectionHandle [javadoc | source]
java.lang.Object
   org.enhydra.jdbc.util.JdbcUtil
      org.enhydra.jdbc.core.CoreConnection
         org.enhydra.jdbc.standard.StandardConnectionHandle

All Implemented Interfaces:
    Connection

Direct Known Subclasses:
    SybaseConnectionHandle, StandardXAConnectionHandle, InformixConnectionHandle

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.
Field Summary
 StandardPooledConnection pooledCon     
protected  Hashtable masterPrepStmtCache     
 int preparedStmtCacheSize     
protected  LRUCache preparedStatementCache     
public  Hashtable inUse     
public  boolean isReallyUsed     
Fields inherited from org.enhydra.jdbc.core.CoreConnection:
con
Fields inherited from org.enhydra.jdbc.util.JdbcUtil:
log
Constructor:
 public StandardConnectionHandle(StandardPooledConnection pooledCon,
    Hashtable preparedStatementCache,
    int preparedStmtCacheSize) 
    Constructor.
Method from org.enhydra.jdbc.standard.StandardConnectionHandle Summary:
catchInvoke,   checkPreparedCache,   checkPreparedCache,   close,   createPreparedStatement,   createPreparedStatement,   isClosed,   preInvoke,   prepareCall,   prepareStatement,   prepareStatement,   prepareStatement,   returnToCache,   returnToCache,   setupPreparedStatementCache
Methods from org.enhydra.jdbc.core.CoreConnection:
catchInvoke,   clearWarnings,   close,   commit,   createStatement,   createStatement,   createStatement,   getAutoCommit,   getCatalog,   getHoldability,   getMetaData,   getTransactionIsolation,   getTypeMap,   getWarnings,   isReadOnly,   nativeSQL,   preInvoke,   prepareCall,   prepareCall,   prepareStatement,   prepareStatement,   prepareStatement,   prepareStatement,   prepareStatement,   prepareStatement,   releaseSavepoint,   rollback,   rollback,   setAutoCommit,   setCatalog,   setHoldability,   setReadOnly,   setSavepoint,   setSavepoint,   setTransactionIsolation,   setTypeMap
Methods from org.enhydra.jdbc.util.JdbcUtil:
setLogger
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.enhydra.jdbc.standard.StandardConnectionHandle Detail:
 public  void catchInvoke(SQLException e) throws SQLException 
    Exception management : catch or throw the exception
 synchronized PreparedStatement checkPreparedCache(String sql,
    int autogeneratedkeys) throws SQLException 
 synchronized PreparedStatement checkPreparedCache(String sql,
    int type,
    int concurrency,
    int holdability) throws SQLException 
    Checks to see if a prepared statement with the same concurrency has already been created. If not, then a new prepared statement is created and added to the cache. If a prepared statement is found in the cache then it is removed from the cache and placed on the "inUse" list. This ensures that if multiple threads use the same StandardConnectionHandle, or a single thread does multiple prepares using the same SQL, then DIFFERENT prepared statements will be returned.
 public synchronized  void close() throws SQLException 
    Closes this StandardConnectionHandle and prevents it from being reused. It also returns used PreparedStatements to the PreparedStatement cache and notifies all listeners.
 protected PreparedStatement createPreparedStatement(String sql,
    int autogeneratedkeys) throws SQLException 
 protected PreparedStatement createPreparedStatement(String sql,
    int type,
    int concurrency,
    int holdability) throws SQLException 
 public boolean isClosed() throws SQLException 
 public  void preInvoke() throws SQLException 
    Pre-invokation of the delegation, in case of connection is closed, we throw an exception
 public CallableStatement prepareCall(String sql,
    int resultSetType,
    int resultSetConcurrency) throws SQLException 
 public PreparedStatement prepareStatement(String sql) throws SQLException 
    Creates a PreparedStatement for the given SQL. If possible, the statement is fetched from the cache.
 public PreparedStatement prepareStatement(String sql,
    int resultSetType,
    int resultSetConcurrency) throws SQLException 
    Creates a PreparedStatement for the given SQL, type and concurrency. If possible, the statement is fetched from the cache.
 public PreparedStatement prepareStatement(String sql,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) throws SQLException 
  void returnToCache(Object key) 
  void returnToCache(Object key,
    Connection theCon) 
    Removes a prepared statement from the inUse list and returns it to the cache.
 protected  void setupPreparedStatementCache()