Examples of using configuration properties to start a JDBC trace
You can control tracing of JDBC applications without modifying those applications.
Example of writing trace data to one trace file for each connection
- Trace information for each connection on the same DataSource is written to a separate trace file. Output goes into a directory named /Trace.
- Each trace file name begins with jccTrace1.
- If trace files with the same names already exist, the trace data is appended to them.
Although Test.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.
- db2.jcc.traceDirectory=/Trace
- db2.jcc.traceFile=jccTrace1
- db2.jcc.traceFileAppend=true
java -Ddb2.jcc.propertiesFile=/Test/jcc.properties Test
- /Trace/jccTrace1_global_0
- /Trace/jccTrace1_global_1
Example of doing a circular trace with a fixed number of files and fixed file size
- Trace information for each connection on the same DataSource is written to a separate set of trace files.
- The maximum number of trace files that are written for each connection is 4.
- When all trace files are full, the trace overwrites existing trace data, beginning with the first trace file that was written.
- The maximum size of each trace file is 4 MB.
- Each trace file name begins with jcc.log, and is written into a directory named /Trace.
- If trace files with the same names already exist, the trace data is overwritten.
Although Test.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.
- db2.jcc.traceFile=jcc.log
- db2.jcc.traceOption=1
- db2.jcc.traceFileSize=4194304
- db2.jcc.traceFileCount=4
- db2.jcc.traceFileAppend=false
java -Ddb2.jcc.propertiesFile=/Test/jcc.properties Test
Suppose that Test.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. During execution of the program, the IBM Data Server Driver for JDBC and SQLJ writes 17 MB of data for the first connection, and 10 MB of data for the second connection.
When the program completes, the following files contain the trace data:
- /Trace/jcc.log_global_0.1
- /Trace/jcc.log_global_0.2
- /Trace/jcc.log_global_0.3
- /Trace/jcc.log_global_0.4
- /Trace/jcc.log_global_1.1
- /Trace/jcc.log_global_1.2
- /Trace/jcc.log_global_1.3
/Trace/jcc.log_global_0.1 contains the last 1 MB of trace data that is written for the first connection, which overwrites the first 1 MB of trace data that was written for that connection.