Class StatementCache.CachedStatement
- All Implemented Interfaces:
InvocationHandler
- Enclosing class:
StatementCache
-
Field Summary
Fields inherited from class StatementDecoratorInterceptor.StatementProxy
closed, delegate -
Constructor Summary
ConstructorsConstructorDescriptionCachedStatement(PreparedStatement parent, String sql) Constructs a CachedStatement, recording the physical connection the statement was prepared on as the answer of the statement itself (or, when that answer is not a physical connection the cache can read, of the pool's own record of the session the prepare ran on). -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the close method is invoked on the statement.voidForces immediate closure of this cached statement.Returns the physical connection this statement was prepared on.org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKeyReturns the cache key for this statement.voidsetCacheKey(org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey cacheKey) Sets the cache key for this statement.Methods inherited from class StatementDecoratorInterceptor.StatementProxy
equals, getActualProxy, getConnection, getConstructor, getDelegate, getSql, hashCode, setActualProxy, setConnection, setConstructor, toString
-
Constructor Details
-
CachedStatement
Constructs a CachedStatement, recording the physical connection the statement was prepared on as the answer of the statement itself (or, when that answer is not a physical connection the cache can read, of the pool's own record of the session the prepare ran on).- Parameters:
parent- the parent prepared statementsql- the SQL text
-
-
Method Details
-
getAssociatedConnection
Returns the physical connection this statement was prepared on.- Returns:
- the connection associated with the statement
-
closeInvoked
Description copied from class:StatementDecoratorInterceptor.StatementProxyCalled when the close method is invoked on the statement.The driver's answer is passed on to the caller:
Statement.close()declaresSQLExceptionfor a database error while closing, and this proxy reports every other call as the delegate answered it, so a failed close must not come back as a success. The swallowed failure this replaces told the application that the statement was closed while the driver had left its resources on the session the pooled connection was about to hand to the next borrower, and nothing along the path recorded or retried it.The handle is retired whichever way the driver answered: the application has been told, and a handle whose close failed must not go on answering calls on a statement the driver may have half released. Where no application waits on the close - the cache dropping a statement, see
StatementCache.closeStatement(StatementCache.CachedStatement)- the failure is answered with a log line instead, so that one statement that will not close cannot stop the rest of that purge.- Overrides:
closeInvokedin classStatementDecoratorInterceptor.StatementProxy<PreparedStatement>- Throws:
SQLException- if the underlying statement could not be closed
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Overrides:
invokein classStatementDecoratorInterceptor.StatementProxy<PreparedStatement>- Throws:
Throwable
-
forceClose
public void forceClose()Forces immediate closure of this cached statement. No application waits on this close - the pool is dropping the statement, from the purge that runs when a session is disconnected or from a cache hit on an entry of a replaced session - so a driver that refuses it is logged rather than thrown: the caller walks the cache, and one statement that will not close must not keep the entries after it from being dropped as well. -
getCacheKey
public org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey getCacheKey()Returns the cache key for this statement.- Returns:
- the cache key
-
setCacheKey
public void setCacheKey(org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey cacheKey) Sets the cache key for this statement.- Parameters:
cacheKey- the cache key
-