You are here :: Home :: Documentation :: JZOS :: Universal JDBC Setup

Configuring and verifying the DB2 Universal JDBC driver under z/OS and JZOS

This document describe how to setup and verify that JDBC is working properly in your environment, independent of the JZOS batch launcher.

Note: These instructions assume that you are running DB2 version 7.1 (with jcc support) , but similar instructions should work for later versions. Refer to the IBM DB2 Java documentation and especially the <DB2HOME>/README file for more information.

Verify that JDBC is properly configured independent of JZOS

  1. Make a copy of the <DB2HOME>/classes/db2sqljjdbc.properties file in your home directory and tailor it for your environment. (At least, modify DB2SQLJSSID to point to your subsystem).
    # Any lines starting with the pound sign '#'
    # are comments. Please see the DB2 for OS/390
    # Application Programming Guide and Reference
    # for Java for the description of these settings.
    #
    DB2SQLJSSID=DBSG
    #DB2SQLJPLANNAME=DSNJDBC
    #DB2SQLJ_TRACE_FILENAME=/tmp/mytrc
    #DB2CURSORHOLD=YES
  2. Under a z/OS Unix shell, create a shell script "db2profile.sh" for configuring the DB2 environment. (tailor this for your installation, and point DB2SQLJPROPERTIES to the file created in Step 1.
    #
    # Set the following shell variables according to your installation.
    #
    export DB2HOME="/usr/lpp/db2/db2710"
    export JAVA_HOME="/usr/lpp/java142/IBM/J1.4"
    DB2HLQ="DBS"
    JCCJARDIR=$DB2HOME/jcc/bin

    export PATH=$JAVA_HOME/bin:$DB2HOME/jcc/bin:$PATH
    LIBPATH=/lib:/usr/lib:$JAVA_HOME/bin
    LIBPATH=$LIBPATH:$JAVA_HOME/bin/classic
    export LIBPATH=$LIBPATH:$DB2HOME/jcc/lib
    CP=$DB2HOME/jcc/bin/db2jcc.jar
    CP=$CP:$DB2HOME/jcc/bin/db2jcc_license_cisuz.jar
    CP=$CP:$DB2HOME/jcc/bin/db2jcc_javax.jar
    CP=$CP:$DB2HOME/jcc/bin/sqlj.zip
    export CLASSPATH=.:$CP
    export DB2SQLJPROPERTIES=~/db2sqljjdbc.properties
    export STEPLIB=$DB2HLQ.SDSNEXIT:$DB2HLQ.SDSNSLOAD:$DB2HLQ.SDSNLOD2
  3. "dot" execute this script so that it configures your current process environment:
    . db2profile.sh
  4. Copy and compile the DB2 sample Java program:
    mkdir tt
    cd tt
    cp $DB2HOME/samples/sample01.java
    javac sample01.java
  5. Run the sample01 java program, which prints the names of the tables in your database:
    java sample01
    **** JDBC Entry within class sample01.
    **** JDBC Connection to DB2 for OS/390.
    **** JDBC Statement Created
    **** JDBC Result Set Created
    Table NAME = ADBTRPT
    Table NAME = ADBTSQL
    Table NAME = PLAN_TABLE
    Table NAME = BP_TBL
    Table NAME = CMDMSG_TBL
    Table NAME = DBSTATUS_TBL
    ...
    **** JDBC Result Set output completed
    **** JDBC Statement Closed
    **** JDBC Disconnect from DB2 for OS/390.
    **** JDBC Exit from class sample01 - no Errors.

Run the sample program under JZOS

Tailor and run the following JCL. Note that this JCL uses the sample01 class created above.

Note: Before running this jcl, you should be sure that you can successfully run the HelloWorld example under JZOS using the JCL provided in <JAVA_HOME>/mvstools/samples/jcl.

//GOETZED JOB (),'GOETZE',MSGCLASS=H,NOTIFY=&SYSUID
//PROCLIB JCLLIB ORDER=GOETZE.JBATCH.JCL
//*
//JAVA EXEC PROC=JVMPRC50,VERSION='14',
// LOGLVL='+D',
// JAVACLS='sample01',
// ARGS=''
//STEPLIB DD
// DD DSN=DBS.SDSNEXIT,DISP=SHR
// DD DSN=DBS.SDSNLOAD,DISP=SHR
// DD DSN=DBS.SDSNLOD2,DISP=SHR
//STDENV DD *
#
#Customize the following variables according to your installation
#
DB2HOME=/usr/lpp/db2/db2710
SQLPROPS=/home/goetze/db2sqljjdbc.properties
CLASSPATH=/home/goetze/tt
JCCJARDIR=$DB2HOME/jcc/bin

export JAVA_HOME=/usr/lpp/java142/IBM/J1.4
export PATH=$JAVA_HOME/bin:$DB2HOME/jcc/bin:/bin
export DB2SQLJPROPERTIES=$SQLJPROPS

LIBPATH=/lib:/usr/lib:$JAVA_HOME/bin
LIBPATH=$LIBPATH:$JAVA_HOME/bin/classic
export LIBPATH=$LIBPATH:$DB2HOME/jcc/lib

CP=$CLASSPATH
CP=$CP:$JCCJARDIR/db2jcc.jar
CP=$CP:$JCCJARDIR/db2jcc_license_cisuz.jar
CP=$CP:$JCCJARDIR/db2jcc_javax.jar
CP=$CP:$JCCJARDIR/sqlj.zip
export CLASSPATH=.:$CP

# Configure JVM options
IJO="-Xms16m -Xmx128m"
export IBM_JAVA_OPTIONS="$IJO "
//