JDBC Type 2 Driver Programmer's Reference for SQL/MX Release 3.2.1 (H06.26+, J06.15+)
8 JDBC Trace Facility
The JDBC trace facility traces the entry point of all JDBC methods called from the Java applications.
To make this facility generic, it is implemented as a JDBC driver wrapper.
The JDBC trace facility can be enabled in any of the following ways in which a JDBC connection
to a database can be obtained:
• “Tracing Using the DriverManager Class” (page 74)
• “Tracing Using the DataSource Implementation” (page 74)
• “Tracing Using the java Command” (page 75)
• “Tracing Using the system.setProperty Method” (page 75)
• “Tracing by Loading the Trace Driver Within the Program” (page 75)
• “Tracing Using a Wrapper Data Source” (page 75)
• “Enabling Tracing for Application Servers” (page 76)
• “Trace-File Output Format” (page 76)
• “Logging SQL Statement IDs and Corresponding JDBC SQL Statements” (page 77)
• “JDBC Trace Facility Demonstration Program” (page 79)
• “Tracing limitation” (page 79)
Tracing Using the DriverManager Class
Java applications can use the DriverManager class to obtain the JDBC connection and enable
the JDBC trace facility by loading the JDBC trace driver. com.tandem.jdbc.TDriver is the
trace driver class that implements the Driver interface. The application can load the JDBC trace
driver in one of the following ways:
• Specify the JDBC trace driver class in the -Djdbc.drivers option in the command line.
• Use the Class.ForName method within the application.
• Add the JDBC trace class to the jdbc.drivers property within the application.
The JDBC URL passed in the getConnection method of the driver class determines which JDBC
driver obtains the connection. Use the following URL and JDBC driver to obtain the JDBC connection:
jdbc:sqlmx:
Java applications should turn on tracing using the DriverManager.setLogWriter method,
for example by using the following JDBC API call in your application:
DriverManager.setLogWriter(new PrintWriter(new FileWriter("FileName")));
Tracing Using the DataSource Implementation
This is preferred way to establish a JDBC connection and to enable the JDBC trace facility. In this
way, a logical name is mapped to a trace data source object by means of a naming service that
uses the Java Naming and Directory Interface (JNDI).
74 JDBC Trace Facility










