public static interface Hook.StatementExecution extends Hook
Hook.CloseConnection, Hook.DestroyConnection, Hook.GetConnection, Hook.GetConnectionTimeout, Hook.InitConnection, Hook.MethodInvocation, Hook.ResultSetRetrieval, Hook.StatementExecution, Hook.StatementProceedingPoint| Modifier and Type | Method and Description |
|---|---|
Object |
on(Statement proxy,
Method method,
Object[] args,
String sqlQuery,
List<Object[]> sqlQueryParams,
Hook.StatementProceedingPoint proceed)
An application hook that will be invoked around the call of each JDBC Statement "execute..." method.
|
Object on(Statement proxy, Method method, Object[] args, String sqlQuery, List<Object[]> sqlQueryParams, Hook.StatementProceedingPoint proceed) throws SQLException
public Object on(Statement proxy, Method method, Object[] args, String sqlQuery, List<Object[]> sqlQueryParams,
StatementProceedingPoint proceed) throws SQLException {
try {
// do something before the real method execution, for example, increment a queriesInProcess counter
// or start a stopwatch
Object result = proceed.on(proxy, method, args, sqlQuery, sqlQueryParams, proceed); // execute it
// examine a thrown SQLException if necessary, retry the Statement execution if appropriate, etc
return result;
} finally {
// do something after the real method execution, for example, decrement a queriesInProcess counter
// or stop a stopwatch
}
}
proxy - the Statement proxy instance that the method was invoked onmethod - the invoked methodargs - the method argumentssqlQuery - the executed SQL query or prepared/callable SQL statementsqlQueryParams - the executed SQL query params if ViburConfig.includeQueryParameters is enabled
and if the sqlQuery was a prepared/callable SQL statement; null otherwise.
The size of the parameters list is equal to the number of the question mark placeholders
in the PreparedStatement query. Each Object[] inside the list contains at index 0
the name of the invoked setXyz method (without the prefix "set") and at the following
indices the parameters of the invoked setXyz method. For an example, see the documentation
for ResultSetRetrieval.
proceed - the proceeding point through which the hook can pass the call to the intercepted Statement
"execute..." method or to the next registered StatementExecution around hook,
if there is suchSQLException - if the underlying method throws such or to indicate an errorCopyright © 2013-2019 vibur.org. All Rights Reserved.