import org.apache.tomcat.jdbc.pool.PooledConnection;
/**
- * Interceptor that keep track of connection state to avoid roundtrips to the database
+ * Interceptor that keep track of connection state to avoid roundtrips to the database.
+ * The {@link org.apache.tomcat.jdbc.pool.ConnectionPool} is optimized to do as little work as possible.
+ * The pool itself doesn't remember settings like {@link java.sql.Connection#setAutoCommit(boolean)},
+ * {@link java.sql.Connection#setReadOnly(boolean)}, {@link java.sql.Connection#setCatalog(String)} or
+ * {@link java.sql.Connection#setTransactionIsolation(int)}. It relies on the application to remember how and when
+ * these settings have been applied.
+ * In the cases where the application code doesn't know or want to keep track of the state, this interceptor helps cache the
+ * state, and it also avoids roundtrips to the database asking for it.
* @author fhanik
*
*/
/**
* Class that resets the abandoned timer on any activity on the
- * Connection or any successful query executions
+ * Connection or any successful query executions.
+ * This interceptor is useful for when you have a {@link org.apache.tomcat.jdbc.pool.PoolConfiguration#setRemoveAbandonedTimeout(int)}
+ * that is fairly low, and you want to reset the abandoned time each time any operation on the connection is performed
+ * This is useful for batch processing programs that use connections for extensive amount of times.
* @author fhanik
*
*/
import org.apache.tomcat.jdbc.pool.ConnectionPool;
import org.apache.tomcat.jdbc.pool.PooledConnection;
/**
- * Keeps track of statements associated with a connection and invokes close upon connection.close()
+ * Keeps track of statements associated with a connection and invokes close upon {@link java.sql.Connection#close()}
+ * Useful for applications that dont close the associated statements after being done with a connection.
* @author fhanik
*
*/
public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) {
// TODO Auto-generated method stub
try {
- statements.add(new WeakReference<Statement>((Statement)statement));
+ if (statement instanceof Statement)
+ statements.add(new WeakReference<Statement>((Statement)statement));
}catch (ClassCastException x) {
//ignore this one
}