New release of JDBC Tools Available: JDBC Tools Version 1.1 offers support for MySQL and Microsoft SQL Server on top of the existing Oracle support to the Query Plan Monitoring module. It also has added support for a filter on execution time, so exception processing can be controlled when SQL query duration exceeds a specified threshold or has changed significantly from previous execution times. Download the new release from here.

In addition, there is an article available showing how to use the new version to effectively diagnose database performance problems in your Java applications. You can read the article here.

JDBC Tools is an open source framework for plugging in monitoring operations to the JDBC layer. The framework is based on a listener infrastructure that works as a proxy JDBC driver and allows you to plug custom listeners into the driver to add any monitoring code that you want into the JDBC layer.

The listener monitors all JDBC calls and allows you to place code before the call is made, after the call has been executed, or in response to an Exception being generated. All you need to do is implement one simple interface.

public class SimpleJDBCMonitor implements JDBCListener {
    public void init() {
        // called once to prepare anything that needs preparing
    }
    public void acceptBefore(ListenerCallEvent event) {
        // put any code in here you want executed before the JDBC call
    }
    public void acceptEnd(ListenerReturnEvent event) {
        // put any code in here you want executed after the JDBC call
    }
    public void acceptException(ListenerExceptionEvent event) {
        // put any code in here you want executed if a SQLException is
        // thrown by the JDBC call
    }
}

Each of the events that is sent into listener methods provides access to the key details of the call. Find out more by looking at the Usage documentation.

The JDBC listener infrastructure allows multiple listeners to be plugged into the JDBC layer, allowing you to maintain a clean separation between different monitoring operations. Listeners can also act as filters, so you can stop a listener from executing by inserting a filter into the listener chain.

As well as coming packaged on it’s own, the JDBC listener can be downloaded packaged with some ready to run example listeners.

  • JDBCLogger is a simple JDBC logging plugin that logs all JDBC calls.
  • JDBCPlanner will extract the SQL from any Statement that is constructed and generate a query explain plan of the SQL. Supports Oracle, MySQL and Microsoft SQL Server by default, and can be extended to other platforms.
  • JDBCCallFilter allows the execution of listeners to be filtered based on the JDBC method that has been called or the application call stack.
  • JDBCDurationFilter allows the execution of listeners to be filter based on the time that a SQL statement has taken to execute.

This allows you to take advantage of the framework straight away and start inspecting the calls your application is making to the database to improve your application performance. Take a look at the Documentation to see how to get started.