Skip to end of metadata
Go to start of metadata

JDBC trace

This page explains when the JDBC trace is used and how it can be configured.


What is JDBC?
What is the content of the JDBC trace?
For which user is the JDBC trace written?
Where are the JDBC trace files located?
How can the JDBC trace settings be changed?
Examples
Further information


What is JDBC?

Java Database Connectivity (JDBC) is a Java driver which provides connectivity to SAP MaxDB databases as well as execution of SQL statements in SAP MaxDB databases from within Java applications.

back to top

What is the content of the JDBC trace?

SAP MaxDB JDBC trace logs JDBC API calls from the Java application including the call parameters. In addition executed SQL statements and their results are written into the trace log.

back to top

For which user is the JDBC trace written?

The JDBC trace is user dependent. It is written only for the operating system user who switches the trace on. So it is required to ensure that the trace is activated from this user who executes the action which is intended to be traced.

back to top

Where are the JDBC trace files located?

The trace files are located in root directory per default. This can be changed by specifying a trace file name including a path.
The trace file name gets a unique number as an appendix. This number looks strange and no context can be recognized at first. It represents the hashcode of the java classloader. This hashcode is used to distinguish the different java threads as there is only one java process. If several trace files are available it is hardly possible to use this number to assign the trace file to a specific trace record. So it is recommended to use the timestamp instead. If several trace files are created in succession it might be a good idea to rename the last ones before creating a new one.

back to top

How can the JDBC trace settings be changed?

The trace settings can be changed on operating system level only. The general command is

java -jar <InstallationPath>\runtime\jar\sapdbc.jar [<option>] [<command>]

Useful information

The <InstallationPath> represents the location where the version dependent MaxDB software is installed. An example is /sapdb/MYDB/db where MYDB is the database name. If the directory is not known it can be detected via command /sapdb/programs/bin/xinstinfo MYDB.
Directory /sapdb/programs/bin represents the version independent program path which can be detected via command dbmcli dbm_getpath IndepProgPath.

Available options are:

-h (help; available options and commands are listed)
-V (lists the version of the installed SAP MaxDB JDBC driver, [be careful: use a capital V])
-d (database name)
-u (database user)
-n (server where the database is running on)

Available commands are:

TRACE ON OFF
To enable and disable the trace

TRACE SIZE <number>
To limit the size of the trace file to <number> Bytes
minimal size is 8192 bytes

TRACE FILENAME <file_name>
Specifies the name of the trace file. A unique appendix is added to the file name.

TRACE STOP ON ERROR <error_number> OFF
Stops trace writing once the error with number <error_number> occurred. Trace is enabled
further on but no trace output is generated.

SHOW [ALL TRACESETTINGS]
Lists the current trace settings.

Handy Hint

Only one command can be executed at the same time. Multiple commands have to be executed successively.

back to top

Examples

Database name is MYDB within the examples below.

Detecting the version of SAP MaxDB JDBC driver:

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar -V
package com.sap.dbtech.jdbc, MaxDB JDBC Driver, SAP AG, 7.6.06 Build
007-000-009 -441 (Make-Version: 7.8.02 Build 022-121-242-659)

Enabling SAP MaxDB JDBC trace:

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar trace on

Configuration:
  Trace              : enabled
  Trace file name    : jdbctrace.prt
  Trace file size    : unlimited
  Stop on error      : disabled
  Shared memory file :
/sapdb/data/wrk/<computer_name>/<user_name>/jdbctrace.shm
  Files will be created in path ./.

Limiting the size of the trace file to 1 MB :

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar trace size 1048576

Configuration:
  Trace              : enabled
  Trace file name    : jdbctrace.prt
  Trace file size    : limited to 1 MBytes
  Stop on error      : disabled
  Shared memory file :
/sapdb/data/wrk/<computer_name>/<user_name>/jdbctrace.shm
  Files will be created in path ./.

Stopping trace writing once error -4004 occurred:

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar trace stop on error -4004

Configuration:
  Trace              : enabled
  Trace file name    : jdbctrace.prt
  Trace file size    : limited to 1 MBytes
  Stop on error      : -4004
  Shared memory file :
/sapdb/data/wrk/<computer_name>/<user_name>/jdbctrace.shm
  Files will be created in path ./.

Listing of the current trace settings:

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar show

Configuration:
  Trace              : enabled
  Trace file name    : jdbctrace.prt
  Trace file size    : limited to 1 MBytes
  Stop on error      : -4004
  Shared memory file :
/sapdb/data/wrk/<computer_name>/<user_name>/jdbctrace.shm
  Files will be created in path ./.

Disabling SAP MaxDB JDBC trace:

java -jar /sapdb/MYDB/db/runtime/jar/sapdbc.jar trace off

Configuration:
  Trace              : disabled
  Trace file name    : jdbctrace.prt
  Trace file size    : unlimited
  Stop on error      : disabled
  Shared memory file :
/sapdb/data/wrk/<computer_name>/<user_name>/jdbctrace.shm
  Files will be created in path ./.

back to top

Further information

See also: SAP notes 903018 and 822239, JDBC, SAP MaxDB Database Trace

back to top

Relevant SAP Notes

903018  FAQ: SAP MaxDB JDBC trace
822239 FAQ: SAP MaxDB Interfaces