From 6fbff1f373c18e334ba3de61902a966323095db4 Mon Sep 17 00:00:00 2001
From: fhanik (String) A semicolon separated list of classnames extending org.apache.tomcat.jdbc.pool.JdbcInterceptor class.
These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
- The default value is null.null.
+ Predefined interceptors:
+ org.apache.tomcat.jdbc.pool.interceptor.ConnectionState - keeps track of auto commit, read only, catalog and transaction isolation level.
+ org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer - keeps track of opened statements, and closes them when the connection is returned to the pool.
+
Interceptors are a powerful way to enable, disable or modify functionality on a specific connection or its sub components.
+ There are many different use cases for when interceptors are useful. By default, and for performance reasons, the connection pool is stateless.
+ The only state the pool itself inserts are defaultAutoCommit, defaultReadOnly, defaultTransactionIsolation, defaultCatalog if
+ these are set. These 4 properties are only set upon connection creation. Should these properties be modified during the usage of the connection,
+ the pool itself will not reset them.
An interceptor has to extend the org.apache.tomcat.jdbc.pool.JdbcInterceptor class. This class is fairly simple,
+ You will need to have a no arg constructor
+ When a connection is borrowed from the pool, the interceptor can initialize or in some other way react to the event by implementing the
+ ConnectionPool parent
+ and a reference to the underlying connection PooledConnection con.
+
+ When a method on the java.sql.Connection object is invoked, it will cause the
+ Method method is the actual method invoked, and Object[] args are the arguments.
+ To look at a very simple example, where we demonstrate how to make the invokation to java.sql.Connection.close() a noop
+ if the connection has been closed
+ "close".equals(method.getName()).
+ Above we see a direct reference comparison between the method name and static final String reference.
+ According to the JVM spec, method names and static final String end up in a shared constant pool, so the reference comparison should work.
+
Configuring interceptors
+ Interceptors are configured using the jdbcInterceptors property or the setJdbcInterceptors method.
+ An interceptor can have properties, and would be configured like this
+