The IBM® Data Server Driver for JDBC and SQLJ includes diagnostic tools and traces for diagnosing problems during connection and SQL statement execution.
Run the DB2Jcc utility to test a connection to a data server. You provide DB2Jcc with the URL for the data server, for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity or IBM Data Server Driver for JDBC and SQLJ type 2 connectivity. DB2Jcc attempts to connect to the data server, and to execute an SQL statement and a DatabaseMetaData method. If the connection or statement execution fails, DB2Jcc provides diagnostic information about the failure.
Use one of the following procedures to start the trace:
Procedure 1: For IBM Data Server Driver for JDBC and SQLJ type 4 connectivity or IBM Data Server Driver for JDBC and SQLJ type 2 connectivity for DB2® for Linux, UNIX and Windows, the recommended method is to start the trace by setting the db2.jcc.override.traceFile property or the db2.jcc.override.traceDirectory property in the IBM Data Server Driver for JDBC and SQLJ configuration properties file. You can set the db2.jcc.tracePolling and db2.jcc.tracePollingInterval properties before you start the driver to allow you to change global configuration trace properties while the driver is running.
Procedure 3:
If you use the DataSource interface to connect to a data source, invoke the javax.sql.DataSource.setLogWriter method to turn the trace on. With this method, TRACE_ALL is the only available trace level.
After a connection is established, you can turn the trace off or back on, change the trace destination, or change the trace level with the DB2Connection.setJccLogWriter method. To turn the trace off, set the logWriter value to null.
The logWriter property is an object of type java.io.PrintWriter. If your application cannot handle java.io.PrintWriter objects, you can use the traceFile property to specify the destination of the trace output. To use the traceFile property, set the logWriter property to null, and set the traceFile property to the name of the file to which the driver writes the trace data. This file and the directory in which it resides must be writable. If the file already exists, the driver overwrites it.
String url = "jdbc:db2://sysmvs1.stl.ibm.com:5021/san_jose" +
":traceFile=/u/db2p/jcctrace;" +
"traceLevel=" + com.ibm.db2.jcc.DB2BaseDataSource.TRACE_DRDA_FLOWS + ";";
Procedure 5: Use DB2TraceManager methods. The DB2TraceManager class provides the ability to suspend and resume tracing of any type of log writer.
Example of starting a trace using configuration properties: For a complete example of using configuration parameters to collect trace data, see Examples of using configuration properties to start a JDBC trace.
Trace example program: For a complete example of a program for tracing under the IBM Data Server Driver for JDBC and SQLJ, see Example of a trace program under the IBM Data Server Driver for JDBC and SQLJ.
To collect trace data to diagnose problems during the SQLJ customization or bind process, specify the -tracelevel and -tracefile options when you run the db2sqljcustomize or db2sqljbind bind utility.
When the db2.jcc.diagLevelExceptionCode global configuration property is set to -1 and the db2.jcc.dumpDiagLevel global configuration property is set to 1, the IBM Data Server Driver for JDBC and SQLJ collects the diagnostic information for the following SQL codes:
When the db2.jcc.diagLevelExceptionCode global configuration property is set to -1 and the db2.jcc.dumpDiagLevel global configuration property is set to 2, the IBM Data Server Driver for JDBC and SQLJ collects the critical diagnostic information for the following SQL codes:
If the db2.jcc.traceLevel, db2.jcc.override.traceLevel global configuration property, or the traceLevel Connection or DataSource property is set to TRACE_SYSPLEX, data about the data sharing group, such as the server list, automatic client reroute and workload balancing property values, transport pool statistics, and special register values is also collected.
The diagnostic data is written to a file named jccdumptimestamp.log, in the directory that is specified by global configuration property db2.jcc.outputDirectory.
>>-profp--serialized-profile-name------------------------------><
Run the profp utility on the serialized profile for the connection in which the error occurs. If an exception is thrown, a Java™ stack trace is generated. You can determine which serialized profile was in use when the exception was thrown from the stack trace.
The db2sqljprint utility formats information about each SQLJ clause in a serialized profile that is customized for the IBM Data Server Driver for JDBC and SQLJ.
Run the db2sqljprint utility on the customized serialized profile for the connection in which the error occurs.