A full-featered tool for JDBC calls tracing is known as jdbcdslog.
- 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:
- 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.
Edited by: Staff.
Edited by: jvaughan on Mar 30, 2010 1:12 PM
Edited by: staff.