A full-featered tool for JDBC calls tracing is known as jdbcdslog.
Features include:
- can be attached on Connection, Driver or DataSource(XA,Pooling) levels
- can log bind parameters for PreparedStatement and CallableStatement calls
- can log result of queries from ResultSet objects
- can log queries execution time
- logging engine agnostic (thanks to SLF4J, you can use most of popular logging libraries like log4j, apache common logging, java logging or simple printing to System.out)
You have three choices how to configure logging proxy:
- wrap JDBC Connection object in your code.
You can use construction like following in this case:
Connection loggingConnection = ConnectionLoggingProxy.wrap(originalConnection);
- configure JDBC Driver logging proxy.
In this case you should use org.jdbcdslog.DriverLoggingProxy instead of the original JDBC Driver class and use jdbcdslog URL format for connection URL parameter:
jdbc:jdbcdslog:;targetDriver=
- configure JDBC DataSource logging proxy.
In this case you should use org.jdbcdslog.ConnectionPoolXADataSourceProxy class instead of your original DataSource class and pass additional parameter targetDS to the DataBase or URL setting for DataSource.
For more information, configuration examples, jar files and sources please look at project web site: http://code.google.com/p/jdbcdslog/.
Edited by: Staff.
Edited by: jvaughan on Mar 30, 2010 1:12 PM Edited by: staff.