IBM Support

How to enable DB2 JDBC JCC trace on Tomcat and Weblogic

Technical Blog Post


Abstract

How to enable DB2 JDBC JCC trace on Tomcat and Weblogic

Body

In case of collecting DB2 JCC trace on client side, we can find the detail from the following link for standalone java and IBM WebSphere.
Collecting Data: Tracing with the IBM Data Server Driver for JDBC and SQLJ

Then, how can we do the same thing on other WAS products.
All WAS(Web application server) products are basically java processes.
Therefore no matter what product you are using, enabling DB2 JCC trace is not other than the following 3 steps from Java perspective.

1. Creating directory for dumping JCC trace files
2. Creating 'jcc.properties' file.
3. set the parameter '-Ddb2.jcc.propertiesFile' on Java runtime option.


Here are examples for Tomcat.
( I assume you are already using client application using DB2.
 If you need to know how to set up DB2 client application environment on Tomcat, refer the following link as well.
50 DB2 Nuggets #40: Tech Tip - Configuring pureScale Client Affinity with Tomcat

  )

<Tomcat>

Step 1. Create directory for dumping JCC trace files.
    For example, I created 'bcc' directory under $TOMCAT_HOME/logs.
   ( NOTE : The path can be any directory where tomcat running user has write permission. )

   $ mkdir jcc
 

Step 2. Create 'jcc.properties' on a directory.
    For example, I created it under $TOMCAT_HOME/conf
   

$ pwd
/home/tomcat/tomcat8026/conf
$ cat jcc.properties
db2.jcc.traceDirectory=/home/tomcat/tomcat8026/logs/jcc
db2.jcc.traceFile=trace
db2.jcc.traceFileAppend=false
db2.jcc.traceLevel=-1


  ( NOTE : The path 'db2.jcc.traceDirectory' can be any directory. 
                But be sure that you set existing path. Otherwise, all applications will get into problem with 
java.io.FileNotFoundException error. )

Step 3. set the parameter on java option. ( $TOMCAT_HOME/conf/catalina.sh )

....<snippet>....
# Uncomment the following line to make the umask available when using the
# org.apache.catalina.security.SecurityListener
#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"

### junsulee : DB2 jcc trace : put your full path for jcc.properties
JAVA_OPTS="$JAVA_OPTS -Ddb2.jcc.propertiesFile=/home/tomcat/tomcat8026/conf/jcc.properties"


.....<snippet>....


Then restart tomcat and run a DB2 client application on Tomcat.
Then you can see the JCC trace files on the directory.
 

$ ls  /home/tomcat/tomcat8026/logs/jcc
trace_global_1    trace_global_2    trace_global_3    trace_global_4


<Weblogic>

Basically the steps are same with step 1 and 2 on tomcat case above.
For the next, set the java option on the Weblogic start shell script.
Here I copied original lines and added the java option. Then, commented the original line.
 

.....<snippet>....

# START WEBLOGIC

echo "starting weblogic with Java version:"

${JAVA_HOME}/bin/java ${JAVA_VM} -version

if [ "${WLS_REDIRECT_LOG}" = "" ] ; then
        echo "Starting WLS with line:"

        #echo "${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}"

        echo "${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Ddb2.jcc.propertiesFile=/home/weblogic/Oracle/Middleware/wlserver_10.3/samples/domains/wl_server/jcc/jcc.properties -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}"


        #${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}

        ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Ddb2.jcc.propertiesFile=/home/weblogic/Oracle/Middleware/wlserver_10.3/samples/domains/wl_server/jcc/jcc.properties -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}

else
        echo "Redirecting output from WLS window to ${WLS_REDIRECT_LOG}"
        #${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}  >"${WLS_REDIRECT_LOG}" 2>&1

        ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} -Ddb2.jcc.propertiesFile=/home/weblogic/Oracle/Middleware/wlserver_10.3/samples/domains/wl_server/jcc/jcc.properties -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}  >"${WLS_REDIRECT_LOG}" 2>&1
fi

 

...<snippet>....




  

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

UID

ibm11140004