|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsnaq.db.CacheConnection
public final class CacheConnection
Connection wrapper that implements statement caching.
CachedStatement,
CachedPreparedStatement,
CachedCallableStatement| Field Summary | |
|---|---|
protected org.apache.commons.logging.Log |
logger
Apache Commons Logging instance for writing log entries. |
| Fields inherited from interface java.sql.Connection |
|---|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
|---|---|
CacheConnection(ConnectionPool pool,
Connection con)
Creates a new CacheConnection object, using the supplied Connection. |
|
| Method Summary | ||
|---|---|---|
void |
clearWarnings()
|
|
void |
close()
Overrides method to provide caching support. |
|
void |
commit()
|
|
Array |
createArrayOf(String typeName,
Object[] elements)
|
|
Blob |
createBlob()
|
|
Clob |
createClob()
|
|
NClob |
createNClob()
|
|
SQLXML |
createSQLXML()
|
|
Statement |
createStatement()
Overrides method to provide caching support. |
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Overrides method to provide caching support. |
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Overrides method to provide caching support. |
|
Struct |
createStruct(String typeName,
Object[] attributes)
|
|
protected void |
flushOpenCallableStatements()
Flushes the open CallableStatement cache for this connection. |
|
protected void |
flushOpenNonCachableStatements()
Flushes the non-cachable Statement instances for this connection. |
|
protected void |
flushOpenPreparedStatements()
Flushes the open PreparedStatement cache for this connection. |
|
protected void |
flushOpenStatements()
Flushes the open Statement cache for this connection. |
|
protected void |
flushSpareCallableStatements()
Flushes the spare CallableStatement cache for this connection. |
|
protected void |
flushSparePreparedStatements()
Flushes the spare PreparedStatement cache for this connection. |
|
protected void |
flushSpareStatements()
Flushes the spare Statement caches for this connection. |
|
boolean |
getAutoCommit()
|
|
String |
getCatalog()
|
|
Properties |
getClientInfo()
|
|
String |
getClientInfo(String name)
|
|
Connection |
getConnection()
|
|
Connection |
getDelegateConnection()
Returns the delegate Connection instance for which this provides
a wrapper. |
|
int |
getHoldability()
|
|
DatabaseMetaData |
getMetaData()
|
|
int |
getOpenCallableStatementCount()
Returns the current number of CallableStatement instances that are in use. |
|
int |
getOpenNonCachableStatementCount()
Returns the current number of non-cachable statements that are in use. |
|
int |
getOpenPreparedStatementCount()
Returns the current number of PreparedStatement instances that
are in use (not including CallableStatement instances). |
|
int |
getOpenStatementCount()
Returns the current number of Statement instances that are in use
(not including PreparedStatement or CallableStatement instances). |
|
protected ConnectionPool |
getPool()
Returns the ConnectionPool to which this CacheConnection belongs. |
|
int |
getSpareCallableStatementCount()
Returns the current number of spare CallableStatement instances that are cached. |
|
int |
getSparePreparedStatementCount()
Returns the current number of spare PreparedStatement instances that are cached. |
|
int |
getSpareStatementCount()
Returns the current number of spare Statements that are cached. |
|
int |
getTransactionIsolation()
|
|
Map<String,Class<?>> |
getTypeMap()
|
|
SQLWarning |
getWarnings()
|
|
boolean |
isCachingAllStatements()
Returns whether caching of all Statement instances is enabled. |
|
boolean |
isCachingCallableStatements()
Returns whether caching of CallableStatement instances is enabled. |
|
boolean |
isCachingPreparedStatements()
Returns whether caching of PreparedStatement instances is enabled. |
|
boolean |
isCachingStatements()
Returns whether caching of standard Statement instances is enabled. |
|
boolean |
isClosed()
|
|
boolean |
isDirty()
Determines if this object is "dirty" (i.e. |
|
boolean |
isReadOnly()
|
|
boolean |
isValid(int timeout)
|
|
boolean |
isWrapperFor(Class<?> iface)
|
|
protected void |
log_debug(String s)
Logging relay method (to prefix pool name). |
|
protected void |
log_debug(String s,
Throwable throwable)
Logging relay method (to prefix pool name). |
|
protected void |
log_warn(String s)
Logging relay method (to prefix pool name). |
|
protected void |
log_warn(String s,
Throwable throwable)
Logging relay method (to prefix pool name). |
|
String |
nativeSQL(String sql)
|
|
CallableStatement |
prepareCall(String sql)
Overrides method to provide caching support. |
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
Overrides method to provide caching support. |
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Overrides method to provide caching support. |
|
PreparedStatement |
prepareStatement(String sql)
Overrides method to provide caching support. |
|
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys)
|
|
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes)
|
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Overrides method to provide caching support. |
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Overrides method to provide caching support. |
|
PreparedStatement |
prepareStatement(String sql,
String[] columnNames)
|
|
void |
recycle()
Puts the connection back in a state where it can be reused. |
|
void |
release()
Destroys the wrapped Connection instance. |
|
void |
releaseSavepoint(Savepoint savepoint)
|
|
void |
rollback()
|
|
void |
rollback(Savepoint savepoint)
|
|
void |
setAutoCommit(boolean autoCommit)
|
|
void |
setCacheAll(boolean cache)
Sets whether to use caching for all types of Statement. |
|
void |
setCacheCallableStatements(boolean cache)
Sets whether to use caching for CallableStatement instances. |
|
void |
setCachePreparedStatements(boolean cache)
Sets whether to use caching for PreparedStatement instances. |
|
void |
setCacheStatements(boolean cache)
Sets whether to use caching for Statement instances. |
|
void |
setCatalog(String catalog)
|
|
void |
setClientInfo(Properties properties)
|
|
void |
setClientInfo(String name,
String value)
|
|
void |
setHoldability(int holdability)
|
|
void |
setReadOnly(boolean readOnly)
|
|
Savepoint |
setSavepoint()
|
|
Savepoint |
setSavepoint(String name)
|
|
void |
setTransactionIsolation(int level)
|
|
void |
setTypeMap(Map<String,Class<?>> map)
|
|
void |
statementClosed(CachedStatement s)
Callback invoked when a CachedStatement is closed. |
|
|
unwrap(Class<T> iface)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.logging.Log logger
| Constructor Detail |
|---|
public CacheConnection(ConnectionPool pool,
Connection con)
CacheConnection object, using the supplied Connection.
pool - ConnectionPool to which this CacheConnection belongscon - Connection instance to which database calls should be delegated| Method Detail |
|---|
public void setCacheStatements(boolean cache)
Statement instances.
cache - whether to cache Statement instancespublic void setCachePreparedStatements(boolean cache)
PreparedStatement instances.
cache - whether to cache PreparedStatement instancespublic void setCacheCallableStatements(boolean cache)
CallableStatement instances.
cache - whether to cache CallableStatement instancespublic void setCacheAll(boolean cache)
cache - whether to cache all types of statementpublic boolean isCachingAllStatements()
Statement instances is enabled.
public boolean isCachingStatements()
Statement instances is enabled.
Statement instances are flagged for caching, false otherwise.public boolean isCachingPreparedStatements()
PreparedStatement instances is enabled.
PreparedStatement instances are flagged for caching, false otherwise.public boolean isCachingCallableStatements()
CallableStatement instances is enabled.
CallableStatement instances are flagged for caching, false otherwise.public Connection getDelegateConnection()
Connection instance for which this provides
a wrapper. This is provided as a convenience method for using database-specific
features for which the Connection object needs to be upcast.
(e.g. to use Oracle-specific features needs to be cast to
oracle.jdbc.OracleConnection).
To maintain the stability of the pooling system it is important that the
raw connection is not destabilized when used in this way.
Connection instance being used for database access.protected final ConnectionPool getPool()
ConnectionPool to which this CacheConnection belongs.
This is provided as a convenience for internal library code (testing etc.)
protected void log_warn(String s)
protected void log_warn(String s,
Throwable throwable)
protected void log_debug(String s)
protected void log_debug(String s,
Throwable throwable)
public Statement createStatement()
throws SQLException
createStatement in interface ConnectionSQLException
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
createStatement in interface ConnectionSQLException
public Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
createStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareStatement in interface ConnectionSQLException
public CallableStatement prepareCall(String sql)
throws SQLException
prepareCall in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareCall in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareCall in interface ConnectionSQLException
public void statementClosed(CachedStatement s)
throws SQLException
CachedStatement is closed.
This method should only be called by CachedStatement instances.
SQLException
public String nativeSQL(String sql)
throws SQLException
nativeSQL in interface ConnectionSQLException
public void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionSQLException
public boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLException
public void commit()
throws SQLException
commit in interface ConnectionSQLException
public void rollback()
throws SQLException
rollback in interface ConnectionSQLException
public void recycle()
throws SQLException
ConnectionPool instances.
recycle in interface ReusableSQLExceptionpublic boolean isDirty()
isDirty in interface Reusable
public void close()
throws SQLException
close in interface ConnectionSQLExceptionpublic int getSpareStatementCount()
public int getOpenStatementCount()
Statement instances that are in use
(not including PreparedStatement or CallableStatement instances).
public int getSparePreparedStatementCount()
PreparedStatement instances that are cached.
public int getOpenPreparedStatementCount()
PreparedStatement instances that
are in use (not including CallableStatement instances).
public int getSpareCallableStatementCount()
CallableStatement instances that are cached.
public int getOpenCallableStatementCount()
CallableStatement instances that are in use.
public int getOpenNonCachableStatementCount()
PreparedStatement instances are non-cachable
by virtue of a request made at creation for support for auto-generated keys.)
prepareStatement(String, int),
prepareStatement(String, int[]),
prepareStatement(String, String[])
protected void flushSpareStatements()
throws SQLException
Statement caches for this connection.
SQLException
protected void flushOpenStatements()
throws SQLException
Statement cache for this connection.
SQLException
protected void flushSparePreparedStatements()
throws SQLException
PreparedStatement cache for this connection.
SQLException
protected void flushOpenPreparedStatements()
throws SQLException
PreparedStatement cache for this connection.
SQLException
protected void flushSpareCallableStatements()
throws SQLException
CallableStatement cache for this connection.
SQLException
protected void flushOpenCallableStatements()
throws SQLException
CallableStatement cache for this connection.
SQLException
protected void flushOpenNonCachableStatements()
throws SQLException
Statement instances for this connection.
SQLException
public void release()
throws SQLException
Connection instance.
This method should only be called by ConnectionPool instances.
SQLException
public boolean isClosed()
throws SQLException
isClosed in interface ConnectionSQLException
public DatabaseMetaData getMetaData()
throws SQLException
getMetaData in interface ConnectionSQLException
public void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionSQLException
public boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLException
public void setCatalog(String catalog)
throws SQLException
setCatalog in interface ConnectionSQLException
public String getCatalog()
throws SQLException
getCatalog in interface ConnectionSQLException
public void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface ConnectionSQLException
public int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLException
public SQLWarning getWarnings()
throws SQLException
getWarnings in interface ConnectionSQLException
public void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLException
public Map<String,Class<?>> getTypeMap()
throws SQLException
getTypeMap in interface ConnectionSQLException
public void setTypeMap(Map<String,Class<?>> map)
throws SQLException
setTypeMap in interface ConnectionSQLException
public void setHoldability(int holdability)
throws SQLException
setHoldability in interface ConnectionSQLException
public int getHoldability()
throws SQLException
getHoldability in interface ConnectionSQLException
public Savepoint setSavepoint()
throws SQLException
setSavepoint in interface ConnectionSQLException
public Savepoint setSavepoint(String name)
throws SQLException
setSavepoint in interface ConnectionSQLException
public void rollback(Savepoint savepoint)
throws SQLException
rollback in interface ConnectionSQLException
public void releaseSavepoint(Savepoint savepoint)
throws SQLException
releaseSavepoint in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int[] columnIndexes)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
String[] columnNames)
throws SQLException
prepareStatement in interface ConnectionSQLException
public Connection getConnection()
throws SQLException
SQLException
public boolean isWrapperFor(Class<?> iface)
throws SQLException
isWrapperFor in interface WrapperSQLException
public <T> T unwrap(Class<T> iface)
throws SQLException
unwrap in interface WrapperSQLException
public Clob createClob()
throws SQLException
createClob in interface ConnectionSQLException
public Blob createBlob()
throws SQLException
createBlob in interface ConnectionSQLException
public NClob createNClob()
throws SQLException
createNClob in interface ConnectionSQLException
public SQLXML createSQLXML()
throws SQLException
createSQLXML in interface ConnectionSQLException
public boolean isValid(int timeout)
throws SQLException
isValid in interface ConnectionSQLException
public void setClientInfo(String name,
String value)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public void setClientInfo(Properties properties)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public String getClientInfo(String name)
throws SQLException
getClientInfo in interface ConnectionSQLException
public Properties getClientInfo()
throws SQLException
getClientInfo in interface ConnectionSQLException
public Array createArrayOf(String typeName,
Object[] elements)
throws SQLException
createArrayOf in interface ConnectionSQLException
public Struct createStruct(String typeName,
Object[] attributes)
throws SQLException
createStruct in interface ConnectionSQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||