#I left a memo in order to not forget.
Situation
When you faced HANA JDBC client issue in your CF Java application, you need collect JDBC trace for your application.
How to enable HANA JDBC trace in CF Java Application
You can enable JDBC trace within the container of your application with "cf ssh". I'll describe the steps to do that.
Application restart is required to enable enable SSH access. Therefore, please consider to perform step 1-4 in advance.
- logon to your Cloud Foundry
$ cf login -a <your CF endpoint>

# If you have not installed cf cli, please install it according to this tutorial.
- enable ssh login for your space
#you need space manager role for target space.
$ cf allow-space-ssh <space>

- enable ssh login for your application
#You need space developer role for target space.
$ cf enable-ssh <app-name>

- Restart you application.
$ cf restart <app-name>
- login into application container with ssh
$ cf ssh <app-name>

- create trace directory in container
$ mkdir /tmp/<trace_dir>
- confirm the location of HANA jdbc driver(ngdbc-<version>.jar)
If you uses SAP Java build pack, you will find jdbc driver in the below directory:
/app/BOOT-INF/lib/ngdbc-<version>.jarIf you cannot find jdbc driver, please search with find commandexample:
$ find /app -name ngdbc*
- confirm the location of Java binary file
If you uses SAP Java build pack, you will find jdbc driver in the below directory:
/app/META-INF/.sap_java_buildpack/sapjvm/bin/javaIf you cannot find java binary file, please check your java application process with ps command.example:
$ ps -aef

- configure and enable JDBC trace according to SAP HANA client reference.example:
$ /app/META-INF/.sap_java_buildpack/sapjvm/bin/java -jar ./ngdbc-2.18.13.jar TRACE FILENAME /tmp/trace_dir/jdbctrace_20231201.log
$ /app/META-INF/.sap_java_buildpack/sapjvm/bin/java -jar ./ngdbc-2.18.13.jar TRACE ON
- execute the application to collect JDBC trace.
- disable JDBC traceexample:
$ /app/META-INF/.sap_java_buildpack/sapjvm/bin/java -jar ./ngdbc-2.18.13.jar TRACE OFF
- You can find the JDBC trace in the trace directory.
- If you want to download the trace into your computer, please try the following command or scp command according to the CF document
Windows:
cf ssh <APP> -i <INSTANCE> -c "tar cfz - <LOGDIR_PATH>/*" | tar xfz - -C .
Linux/Mac:
cf ssh <APP> -i <INSTANCE> -c 'tar cfz - <LOGDIR_PATH>/*' | tar xfz - -C .
#This command get "<LOGDIR_PATH>" files into local current directory.
Reminder:
- This configuration will be reset when your application is restaged.
- If your application is running with several container, you need configure them in each container or scale down to only single container.