How to use Castor JDO's connection proxies

# How to use Castor JDO's connection proxies

## Introduction

Castor JDO uses the Jakarta Common's Logging package for output information relevant to the execution of a specific JDO operations to a log file. The information output historically included the SQL statements used by Castor to execute the various persistence operations such as loading or updating domain entities. Unfortunately, the SQL statements logged did not include any information about the parameters being bound to the prepared statements immediately before execution, and hence made it very hard for users of Castor JDO to analyze these in the case of an issue/problem.

To improve this situation, proxy classes for the java.sql.Connection and java.sql.PreparedStatement interfaces have been added, to allow for complete and better JDBC statements to be output to the log files. As this might impose a performance penalty at run-time, we have allowed for this to be turned off completely through the standard Castor property file.

A new property has been added to the Castor property file (`castor.properties`) to allow configuration of this feature.

## Intended Audience

Anyone who wants to use the new JDBC proxy classes with Castor JDO selectively, i.e. enabling and disabling their use.

The example given describes how to turn the use of the proxy classes on/off.

## Prerequisites

You should have a valid `castor.properties` file as part of your application.

## Steps

Here is how to proceed.

### Enable the use of the JDBC proxy classes

To enable the use of the JDBC proxy classes described above, please add the following section to your `castor.properties` file.

      # True if JDBC proxy classes should be used to enable more detailed logging output of SQL
      # statements; false otherwise (logging of SQL statements will be turned off completely).
      #
      org.exolab.castor.persist.useProxy=true

This instructs Castor JDO to use the JDBC proxy classes and to output full information about the SQL statements used at run-time. When disabled, no logging of SQL statements will occur at all.

## References

- Configuration of Castor

- Jakarta Common Logging