public class StatementCache extends StatementDecoratorInterceptor
PreparedStatement
and/or
CallableStatement
instances on a connection.Modifier and Type | Class and Description |
---|---|
protected class |
StatementCache.CachedStatement |
StatementDecoratorInterceptor.ResultSetProxy, StatementDecoratorInterceptor.StatementProxy<T extends java.sql.Statement>
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
ALL_TYPES |
protected static java.lang.String[] |
CALLABLE_TYPE |
protected static java.lang.String[] |
NO_TYPE |
protected static java.lang.String[] |
PREPARED_TYPE |
protected static java.lang.String |
STATEMENT_CACHE_ATTR |
constructors, resultSetConstructor
CREATE_STATEMENT, CREATE_STATEMENT_IDX, EXECUTE, EXECUTE_BATCH, EXECUTE_QUERY, EXECUTE_TYPES, EXECUTE_UPDATE, PREPARE_CALL, PREPARE_CALL_IDX, PREPARE_STATEMENT, PREPARE_STATEMENT_IDX, STATEMENT_TYPE_COUNT, STATEMENT_TYPES
CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL
Constructor and Description |
---|
StatementCache() |
Modifier and Type | Method and Description |
---|---|
boolean |
cacheStatement(StatementCache.CachedStatement proxy) |
void |
closeStatement(StatementCache.CachedStatement st) |
protected 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)
Creates a proxy for a Statement.
|
void |
disconnected(ConnectionPool parent,
PooledConnection con,
boolean finalizing)
Called when
Connection.close() is called on the underlying connection. |
java.util.concurrent.atomic.AtomicInteger |
getCacheSize() |
int |
getMaxCacheSize() |
java.lang.String[] |
getTypes() |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Gets invoked each time an operation on
Connection is invoked. |
boolean |
isCacheCallable() |
StatementCache.CachedStatement |
isCached(java.lang.String sql) |
boolean |
isCachePrepared() |
void |
poolClosed(ConnectionPool pool)
This method is invoked by a connection pool when the pool is closed.
|
void |
poolStarted(ConnectionPool pool)
This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.
|
boolean |
removeStatement(StatementCache.CachedStatement proxy) |
void |
reset(ConnectionPool parent,
PooledConnection con)
no-op for this interceptor. no state is stored.
|
void |
setProperties(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
|
closeInvoked, createStatement, getConstructor, getResultSetConstructor, isExecuteQuery, isExecuteQuery
isExecute, isStatement, process
compare, compare, getNext, getProperties, isUseEquals, setNext, setUseEquals
protected static final java.lang.String[] ALL_TYPES
protected static final java.lang.String[] CALLABLE_TYPE
protected static final java.lang.String[] PREPARED_TYPE
protected static final java.lang.String[] NO_TYPE
protected static final java.lang.String STATEMENT_CACHE_ATTR
public boolean isCachePrepared()
public boolean isCacheCallable()
public int getMaxCacheSize()
public java.lang.String[] getTypes()
public java.util.concurrent.atomic.AtomicInteger getCacheSize()
public void setProperties(java.util.Map<java.lang.String,PoolProperties.InterceptorProperty> properties)
JdbcInterceptor
setProperties
in class JdbcInterceptor
public void poolStarted(ConnectionPool pool)
JdbcInterceptor
poolStarted
in class JdbcInterceptor
pool
- - the pool that is being closed.public void poolClosed(ConnectionPool pool)
JdbcInterceptor
poolClosed
in class JdbcInterceptor
pool
- - the pool that is being closed.public void reset(ConnectionPool parent, PooledConnection con)
AbstractCreateStatementInterceptor
reset
in class AbstractCreateStatementInterceptor
parent
- - the connection pool owning the connectioncon
- - the pooled connectionpublic void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing)
JdbcInterceptor
Connection.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.disconnected
in class JdbcInterceptor
parent
- - the connection pool that this connection belongs tocon
- - the pooled connection that holds this connectionfinalizing
- - if this connection is finalizing. True means that the pooled connection will not reconnect the underlying connectionpublic void closeStatement(StatementCache.CachedStatement st)
protected 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.InvocationTargetException
StatementDecoratorInterceptor
createDecorator
in class StatementDecoratorInterceptor
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 proxyargs
- The arguments passed as part of the method call to
the proxystatement
- The statement object that is to be proxiedconstructor
- The constructor for the desired proxysql
- The sql of of the statementjava.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
AbstractCreateStatementInterceptor
Connection
is invoked.
invoke
in interface java.lang.reflect.InvocationHandler
invoke
in class AbstractCreateStatementInterceptor
java.lang.Throwable
public StatementCache.CachedStatement isCached(java.lang.String sql)
public boolean cacheStatement(StatementCache.CachedStatement proxy)
public boolean removeStatement(StatementCache.CachedStatement proxy)
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.