Installation

There are three things you need to do in order for JDBC Logger to show you the SQL statements in clear:

  • place the JDBC file jar file(s) in your classpath. Use the all in one package, or only those modules that you need (jdbclogger-core-version.jar beeing the only one absolutely required).
  • specify the JDBC driver(s) that you use and want to wrapp.
  • use the net.sourceforge.jdbclogger.JdbcLoggerDriver class name as your driver name.

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

Specifying the target JDBC Driver(s) in a properties file

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.

Specifying the target JDBC Driver(s) as system properties

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 ...

Installation in a Maven 2 built project

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>

And add the dependencies to your Maven project:

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>