Example Of Using Configuration Properties To Start A Jdbc Trace - IBM DB2 Manual

Table of Contents

Advertisement

Formatting information about an SQLJ customized serialized
profile
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.

Example of using configuration properties to start a JDBC trace

You can control tracing of JDBC applications without modifying those applications.
Suppose that you want to collect trace data for a program named Test.java, which
uses IBM Data Server Driver for JDBC and SQLJ type 4 connectivity. Test.java does
no tracing, and you do not want to modify the program, so you enable tracing
using configuration properties. You want your trace output to have the following
characteristics:
v Trace information for each connection on the same DataSource is written to a
v Each trace file name begins with jccTrace1.
v If trace files with the same names already exist, the trace data is appended to
Although Test1.java does not contain any code to do tracing, you want to set the
configuration properties so that if the application is modified in the future to do
tracing, the settings within the program will take precedence over the settings in
the configuration properties. To do that, use the set of configuration properties that
begin with db2.jcc, not db2.jcc.override.
The configuration property settings look like this:
v db2.jcc.traceDirectory=/Trace
v db2.jcc.traceFile=jccTrace1
v db2.jcc.traceFileAppend=true
You want the trace settings to apply only to your stand-alone program Test1.java,
so you create a file with these settings, and then refer to the file when you invoke
the Java program by specifying the -Ddb2.jcc.propertiesFile option. Suppose that
the file that contains the settings is /Test/jcc.properties. To enable tracing when
you run Test1.java, you issue a command like this:
java -Ddb2.jcc.propertiesFile=/Test/jcc.properties Test1
Suppose that Test1.java creates two connections for one DataSource. The program
does not define a logWriter object, so the driver creates a global logWriter object
for the trace output. When the program completes, the following files contain the
trace data:
v /Trace/jccTrace1_global_0
v /Trace/jccTrace1_global_1
Related reference
"DB2Connection interface" on page 326
"db2sqljprint - SQLJ profile printer" on page 412
separate trace file. Output goes into a directory named /Trace.
them.
Chapter 15. Problem diagnosis with the IBM Data Server Driver for JDBC and SQLJ
485

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents