An interceptor is a software design pattern that provides a transparent way to extend or modify some aspect of a program, similar to a user exit. No recompiling is required. With Connector/J, the interceptors are enabled and disabled by updating the connection string to refer to different sets of interceptor classes that you instantiate.
The connection properties that control the interceptors are explained in Section 5.1, “Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J”:
connectionLifecycleInterceptors, where you specify the fully qualified names of classes that implement the
com.mysql.jdbc.ConnectionLifecycleInterceptorinterface. In these kinds of interceptor classes, you might log events such as rollbacks, measure the time between transaction start and end, or count events such as calls to
exceptionInterceptors, where you specify the fully qualified names of classes that implement the
com.mysql.jdbc.ExceptionInterceptorinterface. In these kinds of interceptor classes, you might add extra diagnostic information to exceptions that can have multiple causes or indicate a problem with server settings. Because
exceptionInterceptorsclasses are only called when handling a
SQLExceptionthrown from Connector/J code, they can be used even in production deployments without substantial performance overhead.
statementInterceptors, where you specify the fully qualified names of classes that implement the
com.mysql.jdbc.StatementInterceptorV2interface. In these kinds of interceptor classes, you might change or augment the processing done by certain kinds of statements, such as automatically checking for queried data in a memcached server, rewriting slow queries, logging information about statement execution, or route requests to remote servers.