|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ConnectionHook
Interface to the hooking mechanism of a connection lifecycle. Applications
will generally want to extend AbstractConnectionHook instead to provide a
default implementation. Applications might also want to make use of
connection.setDebugHandle(...) to keep track of additional information on
each connection.
Since the class is eventually loaded via reflection, the implementation must
provide a public, no argument constructor.
Warning: Be careful to make sure that the hook methods are re-entrant and
thread-safe; do not rely on external state without appropriate locking, use appropriate
synchronization!
| Method Summary | |
|---|---|
void |
onAcquire(ConnectionHandle connection)
Called upon getting a new connection from the JDBC driver (and prior to inserting into the pool). |
boolean |
onAcquireFail(Throwable t,
AcquireFailConfig acquireConfig)
Called on attempting (and failing) to acquire a connection. |
void |
onAfterStatementExecute(ConnectionHandle conn,
StatementHandle statement,
String sql,
Map<Object,Object> params)
Called right after a statement has executed. |
void |
onBeforeStatementExecute(ConnectionHandle conn,
StatementHandle statement,
String sql,
Map<Object,Object> params)
Called before a statement is about to execute. |
void |
onCheckIn(ConnectionHandle connection)
Called when the connection is about to be returned to the pool. |
void |
onCheckOut(ConnectionHandle connection)
Called when the connection is extracted from the pool and about to be given to the application. |
boolean |
onConnectionException(ConnectionHandle connection,
String state,
Throwable t)
Called whenever an exception on a connection occurs. |
void |
onDestroy(ConnectionHandle connection)
Called when the connection is about to be completely removed from the pool. |
ConnectionState |
onMarkPossiblyBroken(ConnectionHandle connection,
String state,
SQLException e)
Called to give you a chance to override the logic on whether a connection can be considered broken or not. |
void |
onQueryExecuteTimeLimitExceeded(ConnectionHandle conn,
Statement statement,
String sql,
Map<Object,Object> logParams)
Deprecated. |
void |
onQueryExecuteTimeLimitExceeded(ConnectionHandle conn,
Statement statement,
String sql,
Map<Object,Object> logParams,
long timeElapsedInNs)
Called when a query execute time limit has been set and an executing query took longer to than the limit to return control to the application. |
void |
onQueryExecuteTimeLimitExceeded(String sql,
Map<Object,Object> logParams)
Deprecated. |
| Method Detail |
|---|
void onAcquire(ConnectionHandle connection)
connection - Handle to the new connectionvoid onCheckIn(ConnectionHandle connection)
connection - being returned to pool.void onCheckOut(ConnectionHandle connection)
connection - about to given to the app.void onDestroy(ConnectionHandle connection)
connection -
boolean onAcquireFail(Throwable t,
AcquireFailConfig acquireConfig)
t - Exception that occurred.acquireConfig - handle containing retry delay, retry attempts etc.
void onQueryExecuteTimeLimitExceeded(ConnectionHandle conn,
Statement statement,
String sql,
Map<Object,Object> logParams,
long timeElapsedInNs)
conn - handle to the connectionstatement - statement handle.sql - SQL statement that was used.logParams - Parameters used in this statement.timeElapsedInNs - actual time the query took (in nanoseconds)
@Deprecated
void onQueryExecuteTimeLimitExceeded(ConnectionHandle conn,
Statement statement,
String sql,
Map<Object,Object> logParams)
conn - handle to the connectionstatement - statement handle.sql - SQL statement that was used.logParams - Parameters used in this statement.
@Deprecated
void onQueryExecuteTimeLimitExceeded(String sql,
Map<Object,Object> logParams)
sql - SQL statement that was used.logParams - Parameters used in this statement.
void onBeforeStatementExecute(ConnectionHandle conn,
StatementHandle statement,
String sql,
Map<Object,Object> params)
conn - Connection handlestatement - Handle to the statementsql - SQL statement about to be executed.params - parameters currently bound to the statement
void onAfterStatementExecute(ConnectionHandle conn,
StatementHandle statement,
String sql,
Map<Object,Object> params)
conn - Connection handlestatement - Handle to the statementsql - SQL statement about to be executed.params - parameters currently bound to the statement
boolean onConnectionException(ConnectionHandle connection,
String state,
Throwable t)
SQLSTATE Value
Value Meaning
08001 The application requester is unable to establish the connection.
08002 The connection already exists.
08003 The connection does not exist.
08004 The application server rejected establishment of the connection.
08007 Transaction resolution unknown.
08502 The CONNECT statement issued by an application process running with a SYNCPOINT of TWOPHASE has failed, because no transaction manager is available.
08504 An error was encountered while processing the specified path rename configuration file.
SQL Failure codes 08001, 08007 & 57P01 indicate that the database is broken/died (and thus all remaining connections are killed off).
Anything else will be taken as the connection (not the db) being broken.
Note: You may use pool.isConnectionHandleAlive(connection) to verify if the connection is in a usable state again. Note 2: As in all interceptor hooks, this method may be called concurrently so any implementation must be thread-safe.
connection - The handle that triggered this errorstate - the SQLState error code.t - Exception that caused this failure.
ConnectionState onMarkPossiblyBroken(ConnectionHandle connection,
String state,
SQLException e)
connection - The handle that triggered this errorstate - the SQLState error code.e - Exception that caused us to call this hook.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||