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

Configuring and verifying Legacy Type 2 (Native) JDBC under z/OS

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

Note: This document describes how to set up the legacy DB2 type 2 driver under z/OS. For newer versions of DB2 (7.1 and up) the universal (jcc) driver should be used. Instructions can be found here: Configuring and verifying the DB2 Universal JDBC driver under z/OS

These instructions describe how to setup and test the Type 2 (native) JDBC drivers for DB2. If Type 4 (thin) drivers are to be used, this step is not necessary.

Note: These instructions assume that you are running DB2 version 7.1.0, but similar instructions should work for other versions. Refer to the IBM DB2 Java documentation and especially the <DB2HOME>/README file for more information.

  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).
    #
    # This file copied from $DB2HOME/classes/db2sqljjdbc.properties.
    # The only parameter changed was DB2SQLJSSID.
    #
    # This DBRMLIB is specific for the DB7G subsystem and the JDBC driver
    #
    DB2SQLJDBRMLIB=DSN710.DBRMLIB.DATA
    #
    #
    # This is installation specific: the name of the DB2 subsystem to use
    #
    DB2SQLJSSID=DSN1
    #
    #
    # The next 5 items are defaults which are coded for documenation
    #
    DB2SQLJPLANNAME=DSNJDBC
    DB2SQLJJDBCPROGRAM=DSNJDBC
    DB2SQLJMULTICONTEXT=YES
    DB2SQLJATTACHTYPE=RRSAF
    DB2CURSORHOLD=YES
    #
    #
    # The following items are for tracing, there are no defaults
    #
    #DB2SQLJ_TRACE_FILENAME=/tmp/mytrc
    #DB2SQLJ_TRACE_BUFFERSIZE=256
    #DB2SQLJ_TRACE_WRAP=1
    #
    #
    db2.connpool.max.size=100
    #
    db2.jdbc.profile.pathname=/usr/lpp/db2/db2710/classes/DSNJDBC_JDBCProfile.ser
    #
  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.
    #
    # Sample shell script for configuring DB2 environment variables
    # See: $DB2HOME/README for more information
    #
    export DB2HOME="/usr/lpp/db2/db2710"
    DB2HLQ="DSN710"
    export PATH="$PATH":"$DB2HOME"/bin
    export LIBPATH="$LIBPATH":"$DB2HOME"/lib
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$DB2HOME"/lib
    export CLASSPATH=.:"$DB2HOME"/classes/db2j2classes.zip:"$CLASSPATH"
    export DB2SQLJPROPERTIES=~/db2sqljjdbc.properties
    export STEPLIB="$DB2HLQ".SDSNEXIT:"$DB2HLQ".SDSNLOAD:"$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.