Class StatementCache
- java.lang.Object
- 
- org.apache.tomcat.jdbc.pool.JdbcInterceptor
- 
- org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
- 
- org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor
- 
- org.apache.tomcat.jdbc.pool.interceptor.StatementCache
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.reflect.InvocationHandler,- StatementCacheMBean
 
 public class StatementCache extends StatementDecoratorInterceptor implements StatementCacheMBean Interceptor that cachesPreparedStatementand/orCallableStatementinstances on a connection.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classStatementCache.CachedStatement- 
Nested classes/interfaces inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptorStatementDecoratorInterceptor.ResultSetProxy, StatementDecoratorInterceptor.StatementProxy<T extends java.sql.Statement>
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static java.lang.String[]ALL_TYPESprotected static java.lang.String[]CALLABLE_TYPEprotected static java.lang.String[]NO_TYPEprotected static java.lang.String[]PREPARED_TYPEprotected static java.lang.StringSTATEMENT_CACHE_ATTR- 
Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptorEXECUTE_QUERY, GET_GENERATED_KEYS, GET_RESULTSET, RESULTSET_TYPES, resultSetConstructor
 - 
Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptorconstructors, CREATE_STATEMENT, CREATE_STATEMENT_IDX, EXECUTE, EXECUTE_BATCH, EXECUTE_TYPES, EXECUTE_UPDATE, PREPARE_CALL, PREPARE_CALL_IDX, PREPARE_STATEMENT, PREPARE_STATEMENT_IDX, STATEMENT_TYPE_COUNT, STATEMENT_TYPES
 - 
Fields inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptorCLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL
 
- 
 - 
Constructor SummaryConstructors Constructor Description StatementCache()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancacheStatement(StatementCache.CachedStatement proxy)voidcloseStatement(StatementCache.CachedStatement st)protected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKeycreateCacheKey(java.lang.reflect.Method method, java.lang.Object[] args)protected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKeycreateCacheKey(java.lang.String methodName, java.lang.Object[] args)protected java.lang.ObjectcreateDecorator(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object statement, java.lang.reflect.Constructor<?> constructor, java.lang.String sql)Creates a proxy for a Statement.voiddisconnected(ConnectionPool parent, PooledConnection con, boolean finalizing)Called whenConnection.close()is called on the underlying connection.protected java.util.concurrent.ConcurrentHashMap<org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey,StatementCache.CachedStatement>getCache()java.util.concurrent.atomic.AtomicIntegergetCacheSize()intgetCacheSizePerConnection()intgetMaxCacheSize()java.lang.String[]getTypes()java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)Gets invoked each time an operation onConnectionis invoked.booleanisCacheCallable()StatementCache.CachedStatementisCached(java.lang.reflect.Method method, java.lang.Object[] args)StatementCache.CachedStatementisCached(java.lang.String sql)Deprecated.Unused.booleanisCachePrepared()voidpoolClosed(ConnectionPool pool)This method is invoked by a connection pool when the pool is closed.voidpoolStarted(ConnectionPool pool)This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.booleanremoveStatement(StatementCache.CachedStatement proxy)voidreset(ConnectionPool parent, PooledConnection con)no-op for this interceptor. no state is stored.voidsetProperties(java.util.Map<java.lang.String,PoolProperties.InterceptorProperty> properties)Called during the creation of an interceptor The properties can be set during the configuration of an interceptor Override this method to perform type casts between string values and object properties- 
Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptorcloseInvoked, createStatement, getResultSetConstructor, isExecuteQuery, isExecuteQuery, isResultSet
 - 
Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptorgetConstructor, isExecute, isStatement, process
 - 
Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptorcompare, compare, getNext, getProperties, isUseEquals, setNext, setUseEquals
 
- 
 
- 
- 
- 
Field Detail- 
ALL_TYPESprotected static final java.lang.String[] ALL_TYPES 
 - 
CALLABLE_TYPEprotected static final java.lang.String[] CALLABLE_TYPE 
 - 
PREPARED_TYPEprotected static final java.lang.String[] PREPARED_TYPE 
 - 
NO_TYPEprotected static final java.lang.String[] NO_TYPE 
 - 
STATEMENT_CACHE_ATTRprotected static final java.lang.String STATEMENT_CACHE_ATTR 
 
- 
 - 
Method Detail- 
isCachePreparedpublic boolean isCachePrepared() - Specified by:
- isCachePreparedin interface- StatementCacheMBean
 
 - 
isCacheCallablepublic boolean isCacheCallable() - Specified by:
- isCacheCallablein interface- StatementCacheMBean
 
 - 
getMaxCacheSizepublic int getMaxCacheSize() - Specified by:
- getMaxCacheSizein interface- StatementCacheMBean
 
 - 
getTypespublic java.lang.String[] getTypes() 
 - 
getCacheSizepublic java.util.concurrent.atomic.AtomicInteger getCacheSize() - Specified by:
- getCacheSizein interface- StatementCacheMBean
 
 - 
setPropertiespublic void setProperties(java.util.Map<java.lang.String,PoolProperties.InterceptorProperty> properties) Description copied from class:JdbcInterceptorCalled during the creation of an interceptor The properties can be set during the configuration of an interceptor Override this method to perform type casts between string values and object properties- Overrides:
- setPropertiesin class- JdbcInterceptor
- Parameters:
- properties- The properties
 
 - 
poolStartedpublic void poolStarted(ConnectionPool pool) Description copied from class:JdbcInterceptorThis method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.- Overrides:
- poolStartedin class- JdbcInterceptor
- Parameters:
- pool- - the pool that is being closed.
 
 - 
poolClosedpublic void poolClosed(ConnectionPool pool) Description copied from class:JdbcInterceptorThis method is invoked by a connection pool when the pool is closed. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.- Overrides:
- poolClosedin class- JdbcInterceptor
- Parameters:
- pool- - the pool that is being closed.
 
 - 
resetpublic void reset(ConnectionPool parent, PooledConnection con) Description copied from class:AbstractCreateStatementInterceptorno-op for this interceptor. no state is stored.- Overrides:
- resetin class- AbstractCreateStatementInterceptor
- Parameters:
- parent- - the connection pool owning the connection
- con- - the pooled connection
 
 - 
disconnectedpublic void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) Description copied from class:JdbcInterceptorCalled whenConnection.close()is called on the underlying connection. This is to notify the interceptors, that the physical connection has been released. Implementation of this method should be thought through with care, as no actions should trigger an exception.- Overrides:
- disconnectedin class- JdbcInterceptor
- Parameters:
- parent- - the connection pool that this connection belongs to
- con- - the pooled connection that holds this connection
- finalizing- - if this connection is finalizing. True means that the pooled connection will not reconnect the underlying connection
 
 - 
closeStatementpublic void closeStatement(StatementCache.CachedStatement st) 
 - 
createDecoratorprotected java.lang.Object createDecorator(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object statement, java.lang.reflect.Constructor<?> constructor, java.lang.String sql) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionDescription copied from class:StatementDecoratorInterceptorCreates a proxy for a Statement.- Overrides:
- createDecoratorin class- StatementDecoratorInterceptor
- Parameters:
- proxy- The proxy object on which the method that triggered the creation of the statement was called.
- method- The method that was called on the proxy
- args- The arguments passed as part of the method call to the proxy
- statement- The statement object that is to be proxied
- constructor- The constructor for the desired proxy
- sql- The sql of of the statement
- Returns:
- A new proxy for the Statement
- Throws:
- java.lang.InstantiationException- Couldn't instantiate object
- java.lang.IllegalAccessException- Inaccessible constructor
- java.lang.reflect.InvocationTargetException- Exception thrown from constructor
 
 - 
invokepublic java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.ThrowableDescription copied from class:AbstractCreateStatementInterceptorGets invoked each time an operation onConnectionis invoked.- Specified by:
- invokein interface- java.lang.reflect.InvocationHandler
- Overrides:
- invokein class- AbstractCreateStatementInterceptor
- Throws:
- java.lang.Throwable
 
 - 
isCached@Deprecated public StatementCache.CachedStatement isCached(java.lang.String sql) Deprecated.Unused. Will be removed in Tomcat 9- Parameters:
- sql- The SQL to attempt to match to entries in the statement cache
- Returns:
- The CachedStatement for the given SQL
 
 - 
isCachedpublic StatementCache.CachedStatement isCached(java.lang.reflect.Method method, java.lang.Object[] args) 
 - 
cacheStatementpublic boolean cacheStatement(StatementCache.CachedStatement proxy) 
 - 
removeStatementpublic boolean removeStatement(StatementCache.CachedStatement proxy) 
 - 
getCacheprotected java.util.concurrent.ConcurrentHashMap<org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey,StatementCache.CachedStatement> getCache() 
 - 
getCacheSizePerConnectionpublic int getCacheSizePerConnection() - Specified by:
- getCacheSizePerConnectionin interface- StatementCacheMBean
 
 - 
createCacheKeyprotected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey createCacheKey(java.lang.reflect.Method method, java.lang.Object[] args)
 - 
createCacheKeyprotected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey createCacheKey(java.lang.String methodName, java.lang.Object[] args)
 
- 
 
-