IBM Support

Native JDBC Dynamic Tracing

Troubleshooting


Problem

This document explains how to dynamically start and stop JDBC tracing for the IBM Developer Kit for Java JDBC driver (the native driver).

Resolving The Problem

This document explains how to dynamically start and stop JDBC tracing for the native JDBC driver (IBM Developer Kit for Java). This function is useful in customer production environments where the job with the JVM cannot be ended to start or stop a trace. This document does not explain the trace settings. For more information about the various trace settings and on how to set the JVM properties, see Enabling Trace Options for native JDBC Applications.

Summary

The trace must be enabled before the application starts by using the following JVM properties:

-Djdbc.db2.trace.monitor=true
-Djdbc.db2.trace.config=file:///tmp/jdbctrace.%j.txt


The trace settings can then be modified dynamically by running the JDBC trace administration program ( com.ibm.db2.jdbc.T ). The following example starts two trace properties for the target job.

> ls -l /tmp/jdbc*
  srwxrwxrwx  1 DDILLING  0    0 Mar 25 09:09 /tmp/jdbc.948811-DDILLING-QP0ZSPWP.trace.monitor
  -rwxrwxrwx  1 DDILLING  0 5463 Mar 25 09:09 /tmp/jdbctrace.948811-DDILLING-QP0ZSPWP.txt

> java com.ibm.db2.jdbc.app.T 948811-DDILLING-QP0ZSPWP jdbc.db2.trace=3 jdbc.db2.cli.trace=true


Details
  • Enable the trace. On the application server command line or other Java application command line, use the jdbc.db2.trace.monitor=true property to enable dynamic tracing. This example also directs the output to a file in the /tmp directory. The %j variable holds the fully qualified job name.

    -Djdbc.db2.trace.monitor=true
    -Djdbc.db2.trace.config=file:///tmp/jdbctrace.%j.txt
  • Note we did not turn on JDBC tracing (typically with a -Djdbc.db2.trace=3 property). When the application server starts, you see something similar to the following in the trace file that you specified:

    > cat jdbctrace.339136*
    Jdbc: New Jdbc Trace at Mon Mar 6 09:00:13 2000
    Jdbc: 952333213.41424 000001f7: T.initTrace(): Bring up trace monitor on: /tmp/jdbc.339136-QEJB-KULACK.trace.monitor
    Jdbc: 952333213.98344 000001f8: T@55344.T.Runnable(): Enter trace monitor
    Jdbc: 952333213.98936 000001f8: T@55344.T.Runnable(): Waiting for trace commands
  • You see something similar to the following in the /tmp directory on the system.
    > ls -l /tmp
    total: 3.200 megabytes
    blah blah blah....
    srwxrwxrw- 1 QEJBSVR 0 0 Mar 6 09:00 jdbc.339136-QEJB-KULACK.trace.monitor


    This data describes a local socket that is being monitored by JDBC for job 339136-QEJB-KULACK. Cut and paste this job name into a Java command line, and use the JDBC trace administration tool to send debug commands to the already running job.
  • Here is the usage example of the JDBC trace administration tool:

    > java com.ibm.db2.jdbc.app.T
    kulack java(): Adding properties from JPROPS environment variable.
    Jdbc: 952333306.437744 00000002: T.initTrace(): QIBM_JDBC_TRACE_LEVEL environment variable set, bumping JDBC Tracing to level 1
    Usage: java com.ibm.db2.jdbc.app.T <JOBNUMBER-USER-NAME> <traceCommands>...


    This example presumes that the target job was run with the system property jdbc.db2.trace.monitor=true

    <traceCommands> one or more of:
    jdbc.db2.trace=0 | 1 | 2 | 3
    jdbc.db2.trace.config=stdout | usrtrc | file://<pathtofile>
    Where an example of <pathtofile> is /home/jdbc.%j.trace.txt
    jdbc.db2.malloc.trace=true | false
    jdbc.db2.cli.trace=true | false
    jdbc.db2.jta.tracktx=true | false
  • Here is an example run:

    > java com.ibm.db2.jdbc.app.T 339136-QEJB-KULACK jdbc.db2.trace=3 jdbc.db2.cli.trace=true
    kulack java(): Adding properties from JPROPS environment variable.
    Jdbc: 952333332.419144 00000002: T.startTraceCommands(): target /tmp/jdbc.339136-QEJB-KULACK.trace.monitor
    Jdbc: 952333332.420136 00000002: T.sendNextTraceCommand() jdbc.db2.trace=3
    Jdbc: 952333332.420560 00000002: T.sendNextTraceCommand() jdbc.db2.cli.trace=true
  • After you run the JDBC trace administration tool, the trace output file of the running job now contains the following:

    > cat jdbctrace.339136*
    Jdbc: New Jdbc Trace at Mon Mar 6 09:00:13 2000
    Jdbc: 952333213.41424 000001f7: T.initTrace(): Bring up trace monitor on: /tmp/jdbc.339136-QEJB-KULACK.trace.monitor
    Jdbc: 952333213.98344 000001f8: T@55344.T.Runnable(): Enter trace monitor
    Jdbc: 952333213.98936 000001f8: T@55344.T.Runnable(): Waiting for trace commands
    Jdbc: 952333332.421400 000001f8: T@55344.T.Runnable(): Trace command: <jdbc.db2.trace=3>
    Jdbc: 952333332.422560 000001f8: T@55344.T.Runnable(): Trace command: <jdbc.db2.cli.trace=true>
    Jdbc: 952333332.441928 000001f8: T@55344.T.Runnable(): Waiting for trace commands
    All sorts of normal JDBC trace points....
    Jdbc: 952334110.950176 0000023b: Websphere: 899.614 1ce07 ServletInstan A Loading.servlet:."invoker"
    Jdbc: 952334110.951736 0000023b: Websphere: 899.614 1ce07 ServletInstan A Loading.servlet:."invoker"
    ... etc ...
  • Later, the JDBC trace administration tool can be used to turn off the trace, reset the destination file, or any other operations. The following example turns off tracing.

    > java com.ibm.db2.jdbc.app.T 339136-QEJB-KULACK jdbc.db2.trace=0 jdbc.db2.cli.trace=false
  • IBM WebSphere merged trace: Note in the previous example, those trace points in Red that have WebSphere: tagged on them were created by specifying the additional property on the WebSphere Application Server command line.

    -Djdbc.db2.was.mergetrace=true

    This property cannot be dynamically enabled. The property enables WebSphere tracing (turned on using the trace specification) to proceed to the JDBC trace output destination. This result is not commonly something that you want.

    Caution:
    When WebSphere tracing is turned on using the trace specification but the JDBC trace monitor is used to keep the JDBC tracing turned off until a later time, WebSphere performance might suffer. For example, enabling the WebSphere trace but leaving JDBC tracing disabled causes WebSphere to perform tracing. However, JDBC throws away all trace data until JDBC tracing is enabled later by using the JDBC trace administration tool. Later, the JDBC trace administration tool can turn off the trace, reset the destination file, or perform any other operations.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Component":"Data Access","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Historical Number

29665414

Document Information

More support for:
IBM i

Software version:
Version Independent

Operating system(s):
IBM i

Document number:
644183

Modified date:
29 June 2021

UID

nas8N1019313

Manage My Notification Subscriptions