ahc.jdbc.logger
Class LoggingJdbcDriver

java.lang.Object
  |
  +--ahc.jdbc.logger.LoggingJdbcDriver
All Implemented Interfaces:
java.sql.Driver

public class LoggingJdbcDriver
extends java.lang.Object
implements java.sql.Driver

This class is a JDBC driver that acts as a wrapper around an arbitrary other JDBC driver and logs all calls made to that driver to System.out. It can be used in any way that other JDBC drivers can be used.

The URL is jdbclog:<driver class>:<driver URL>

Putting it all together, the URL could be something like jdbclog:COM.ibm.db2.jdbc.app.DB2Driver:jdbc:db2:test.

In the logging output, every "real" object that is returned by a JDBC call (i.e. something like a Connection or a ResultSet rather than a String, Date or Timestamp) is associated with a unique ID. Whenever a call is made, the ID is logged for the object on which the call is made. That allows you to trace what calls are made on which objects in which sequence.

Note: This logging is very verbose. It is meant for tracking down some rather nasty bugs. When you use it, make sure that you redirect System.out to a file.

Author:
Arno Haase

Field Summary
static java.lang.String URL_PREFIX
           
 
Constructor Summary
LoggingJdbcDriver()
           
 
Method Summary
 boolean acceptsURL(java.lang.String url)
           
 java.sql.Connection connect(java.lang.String url, java.util.Properties info)
           
 int getMajorVersion()
           
 int getMinorVersion()
           
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)
           
 boolean jdbcCompliant()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_PREFIX

public static final java.lang.String URL_PREFIX
See Also:
Constant Field Values
Constructor Detail

LoggingJdbcDriver

public LoggingJdbcDriver()
Method Detail

connect

public java.sql.Connection connect(java.lang.String url,
                                   java.util.Properties info)
                            throws java.sql.SQLException
Specified by:
connect in interface java.sql.Driver
java.sql.SQLException

acceptsURL

public boolean acceptsURL(java.lang.String url)
                   throws java.sql.SQLException
Specified by:
acceptsURL in interface java.sql.Driver
java.sql.SQLException

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                     java.util.Properties info)
                                              throws java.sql.SQLException
Specified by:
getPropertyInfo in interface java.sql.Driver
java.sql.SQLException

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface java.sql.Driver

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface java.sql.Driver

jdbcCompliant

public boolean jdbcCompliant()
Specified by:
jdbcCompliant in interface java.sql.Driver