Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
sakuyuki
Advisor
Advisor
#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.

  1. 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.

  2. enable ssh login for your space
    #you need space manager role for target space.
    $ cf allow-space-ssh <space>​



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



  4. Restart you application.
    $ cf restart <app-name>​

     

  5. login into application container with ssh
    $ cf ssh <app-name>​



  6.  create trace directory in container
    $ mkdir /tmp/<trace_dir>​

     

  7. 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>.jar
    If you cannot find  jdbc driver, please search with find commandexample:
    $ find /app -name ngdbc* 

     

  8.  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/java
    If you cannot find java binary file, please check your java application process with ps command.example:
    $ ps -aef



  9.  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​

     

  10. execute the application to collect JDBC trace.

  11. disable JDBC traceexample:
    $ /app/META-INF/.sap_java_buildpack/sapjvm/bin/java -jar ./ngdbc-2.18.13.jar TRACE OFF​

     

  12. You can find the JDBC trace in the trace directory.

  13. 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.