There are three things you need to do in order for JDBC Logger to show you the SQL statements in clear:
In case you are using the Spring Framework in your project to configure your data source(s), please check out the Integration with Spring page.
The statements are logged by using the commons-logging library, and has been tested with log4j. Make sure you include the following line in your log4j.properties:
log4j.logger.net.sourceforge.jdbclogger=DEBUG
JDBC Logger is able to read a file called <jdbclogger.properties> from the root of your classpath. You need to create such a file, and add a line like this to it:
jdbclogger.driver=org.hsqldb.jdbcDriver
In case you have more than one JDBC Driver used in your application, use the "jdbclogger.driver" name as a prefix, for example:
jdbclogger.driver_1=org.hsqldb.jdbcDriver jdbclogger.driver_2=oracle.jdbc.OracleDriver .......... jdbclogger.driver_n=com.mysql.jdbc.Driver
We have an example in our SVN repository so you can also take a look there.
In case you need to use system properties, you can do so, same rules apply, just that you specify parameters to the JVM, or set them yourself programmaticaly using System.setProperty(). You either do this at the startup of your application, as regular JVM parameters, or make sure you perform these settings programmaticaly before any database connections are to be open. For example:
-Djdbclogger.driver=org.hsqldb.jdbcDriver or -Djdbclogger.driver_1=org.hsqldb.jdbcDriver -Djdbclogger.driver_2=oracle.jdbc.OracleDriver ...
To use JDBC Logger in a maven project you have to add our repository to your pom.xml file. To use our latest release you should add these following lines to your <repositories/> element:
<repository> <id>jdbclogger</id> <name>JDBC Logger private repo</name> <url>http://jdbclogger.sourceforge.net/m2-repo/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository>
In order to use our latest snapshot you have to add these lines:
<repository> <id>jdbclogger-snapshots</id> <name>JDBC Logger private snapshot repo</name> <url>http://jdbclogger.sourceforge.net/m2-repo-snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>
To get the full JDBC logger with all its features, you can use the all in one package:
<dependency> <groupId>net.sourceforge.jdbclogger</groupId> <artifactId>jdbclogger</artifactId> <version>0.6</version> </dependency>
Or you can include only those modules that are usefull to you:
<dependency> <groupId>net.sourceforge.jdbclogger</groupId> <artifactId>jdbclogger-core</artifactId> <version>0.6</version> </dependency> <dependency> <groupId>net.sourceforge.jdbclogger</groupId> <artifactId>jdbclogger-oracle</artifactId> <version>0.6</version> </dependency> <dependency> <groupId>net.sourceforge.jdbclogger</groupId> <artifactId>jdbclogger-spring</artifactId> <version>0.6</version> </dependency>