SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Trace an SAP HANA Client Connection

Enable trace settings for applications using SAP HANA Client interfaces.

Overview

You will learn

  • ✔How to enable tracing using hdbsqldbc_cons, environment variables, or connection parameters
  • ✔How to direct trace details to a file, stdout, stderr, or to a callback

More from Dan van Leeuwen

See all 60 tutorials by Dan van Leeuwen →

Prerequisites

  • You have completed the first 3 tutorials in this mission.

Steps

Platform: Windows macOS Linux

Intro

Trace files can help SAP Support diagnose unexpected behavior.

Tracing can be configured using executables included with the SAP HANA Client installation. SQLDBC-based interfaces use hdbsqldbc_cons, except for ODBC, which uses hdbodbc_cons. For JDBC, use ngdbc.jar.

Trace settings can also be configured using environment variables, or via connection parameters.


Step 1 Enable Tracing
—

  1. Enter the following command to see the current trace settings:

    Shell
    hdbsqldbc_cons SHOW ALL

    hdbsqldbc_cons SHOW ALL Results
    hdbsqldbc_cons SHOW ALL Results

    hdbsqldbc_cons utility can be found in the sap/hdbclient folder.

  2. To enable tracing of SQL statements at the INFO level, to enable tracing of TIMING info, and to specify the trace file location and name, enter the following commands:

Shell
hdbsqldbc_cons TRACE SQL ON LEVEL INFO
hdbsqldbc_cons TRACE TIMING ON
mkdir c:\temp\traces
hdbsqldbc_cons TRACE FILENAME c:\temp\traces\SQLDBC-%p.txt
Shell
hdbsqldbc_cons TRACE SQL ON LEVEL INFO
hdbsqldbc_cons TRACE TIMING ON
mkdir -p /tmp/traces
hdbsqldbc_cons TRACE FILENAME /tmp/traces/SQLDBC-%p.txt
Shell
hdbsqldbc_cons TRACE SQL ON LEVEL INFO
hdbsqldbc_cons TRACE TIMING ON
mkdir -p /tmp/traces
hdbsqldbc_cons TRACE FILENAME /tmp/traces/SQLDBC-%p.txt

The %p will be replaced with the process ID of the traced application. Including %p in the file name ensures that each process can write its own trace file.

The next step provides an example of sending the trace output to stdout or stderr. Another option for Node.js applications is to specify a callback to receive the trace output to using the onTrace method which is shown in the tutorial Connect Using the SAP HANA Node.js Interface.

Example trace categories include:

  • API
  • SQL
  • TIMING

Some trace categories such as SQL also have severity levels:

  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • FATAL

For more information, see SQLDBC Tracing.

To see the current settings run:

Shell
hdbsqldbc_cons SHOW ALL

Trace settings
Trace settings

  1. Run the following command to connect to HDBSQL and query for the status. Since tracing is enabled, a trace file will be generated and can be used to see which SQL statements are called by \s.

    Shell
    hdbsql -U User1UserKey "\s"
  2. Find and open the generated trace file. Remember to replace #### to match the trace file name you wish to open.

Shell
cd c:\temp\traces
dir SQLDBC*.txt /od
notepad SQLDBC-####.txt
Shell
cd /tmp/traces
ls -lt
pico SQLDBC-####.txt
Shell
cd /tmp/traces
ls -lt
pico SQLDBC-####.txt

Replace process ID
Replace process ID

Notice that the trace settings are shown at the top of the file.

Code
libSQLDBCHDB 2.16.18.1676320318
SYSTEM: Microsoft Windows / X64
BUILD AT: 2023-02-13 20:43:00
BRANCH: unknown
BUILD MODE: rel
APPLICATION: C:\SAP\hdbclient\hdbsql.exe
HOST: W-R90XC65K
OS USER: I234567
CURRENT DIRECTORY: c:\temp\traces
TRACE FILE NAME: c:\temp\traces\SQLDBC-55652.txt
PROCESS ID: 55652
TRACE FILE WRAP COUNT: 0

---
Enabled Traces:

SQL Trace: Level INFO
Distribution Trace: Level INFO
Timing Trace

---

If the trace settings change while tracing is enabled, the Enabled Traces section will appear again in the trace file.

If you are experiencing issues with SQLDBC tracing, consult Troubleshooting SQLDBC Tracing.

  1. Search through the trace file and notice the SQL statements that were executed.

    Code
    ::PREPARE SQLCURS_1 2023-04-07 12:46:38.497000 [0x000002540c111af0]
    SQL COMMAND: SELECT VERSION FROM SYS.M_DATABASE
  2. To turn off tracing for all categories, run the following command:

    Shell
    hdbsqldbc_cons TRACE OFF
    hdbsqldbc_cons SHOW ALL
Step 2 Additional Trace Settings
+
Step 3 Tracing a JDBC Connection
+
Step 4 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Enable Tracing 2. Additional Trace Settings 3. Tracing a JDBC Connection 4. Knowledge check
Next