Debug your JDBC API program

There are two mechanisms to generate trace outputs in JDBC. A legacy mechanism SQLDEBUG and a more modern use of a logging framework.

Note: Enabling tracing can have a noticeable impact on driver performance. Enable only logging to assist in diagnosing a problem with the driver.

JDBC Tracing Using Logging

You can enable tracing of the JDBC driver via the logging API Log4j. For JDBC versions 8.1.1.2 and above you will need to include the optional logging library which is found at https://search.maven.org/artifact/org.apache.logging.log4j/log4j-core/2.17.1/jar alongside the JDBC jar file in yoru CLASSPATH.

Important: The JDBC trace feature should only be used when directed by the HCL technical support representative.
You will need to provide to your application an XML configuration file that specifies what and where to log JDBC tracing information. You can take the example XML configuration file for Log4j2 below and save it where you application is running. Notice you can adjust modify the file path as well as the trace level. JDBC will only print events on 'trace' and 'debug' levels to avoid inadvertant printing of trace messages when the driver is used in applications already using Log4j.

This file must exist in the CLASSPATH of the running application or be specified using the Java system property log4j2.configurationFile=/path/to/log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30" status="WARN">
  <Property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %t | %c{1} | %method | %marker | %msg%n</Property>
  <Appenders>
    <File name="console" fileName="/tmp/onedb-jdbc.log">
      <PatternLayout pattern="${pattern}" />
    </File>
  </Appenders>
  <Loggers>
    <!-- Change this to 'trace' to print out driver events -->
    <Root level="trace" additivity="false">
      <AppenderRef ref="console" />
    </Root>
  </Loggers>
</Configuration>        

If you already using Log4j or another logger you can enable JDBC logging by enabling trace events on the JDBC packages.

For more information on the customization and options available using Log4j refer to the Log4j configuration guide at https://logging.apache.org/log4j/2.x/manual/configuration.html

Package Name
com.onedb.jdbc
com.onedb.jdbcx
com.informix

SQLIDEBUG

You can set the SQLIDEBUG connection property to generate binary protocol trace. You set the connection property SQLIDEBUG to specify a file. For example:
SQLIDEBUG=/tmp/jdbctrace.log

A new trace file is generated for every connection and is suffixed with a timestamp. If you are using the OneDBDataSource class, you can use the OneDBDataSource.setPropery("SQLIDEBUG", "/tmp/jdbctrace.log") method.

Important: The binary SQLI protocol trace feature (SQLIDEBUG) should only be used when directed by the HCL technical support representative.