Java and DB2 API, Application Program Interface
Part Three - Challenge #08

Background:

Java connection and interaction with DB2 relational database table

You are NOT expected to have experience with Java to complete the challenge.

However, the Java code provided includes a working example of Java API to connect for read, write,
and update of a DB2 relational database table if you select to carefully review the syntax.

Challenge #08 assumes you successfully completed previous challenge.


You will learn to:
  • Recognize Java code
  • Compile Java code
  • Execute Java code
  • Modify Java code based upon recognizable Java code pattern

Several obstacles and tasks will be encountered to complete the challenge:
  • Copy Java code from partitioned data set to unix file
  • View Java compile failure related to insufficient virtual storage memory
  • Increase TSO virtual storage to complete Java compile
  • View Java execution failure related to authentication
  • Modify Java code correcting issue with authentication failure
  • Java program execution from Unix shell prompt
  • Java program execution using JCL

Challenge:

Copy Java code from partitioned data set to unix file
  1. Jump to ISPF Command Shell panel =6
  2. oput 'zos.mtm2018.public.source(db2jdbc4)' 'db2jdbc4.java'

View Java compile failure related to insufficient virtual storage memory
  1. Jump to Unix Services command shell prompt =u
  2. javac db2jdbc4.java

Carefully reading the failure diagnostics written to the display indicates insufficient virtual storage.


Increase TSO virtual storage to complete Java compile
  1. Logoff ISPF/TSO
  2. Logon to TSO/ISPF with modification to SIZE value on TSO/E LOGON display
      Change value from 32768 to 262144

View Java execution failure related to authentication
  1. Jump to Unix Services command shell prompt =u
  2. javac db2jdbc4.java
  3. java db2jdbc4

Carefully reading the failure diagnostics written to the display indicates connection authorization failure.


Modify Java code correcting issue with authentication failure
From Unix Services shell prompt
  1. oedit db2jdbc4.java
  2. find and change userid, z#####, and wrong password, wrongpwd, to your valid userid and password
  3. f3 to save and exit
  4. javac db2jdbc4.java
  5. java db2jdbc4
If the authentication failure message does not appear, then you successfully resolved the authentication failure. However, execution produced a DB2 SQL Error. Go to next twisty.

Modify Java code correcting issue with DB2 SQL Error

Carefully read the DB2 SQL error that includes SQLERRMC=value
 The value is NOT your table created in the previous challenge
 Read the incorrect table value very carefully
 The value must be an identical match to the table name you previously created and loaded

From Unix Services shell prompt

  1. oedit db2jdbc4.java
  2. find and change the table name to your table from previous challenge
  3. f3 to save and exit
  4. javac db2jdbc4.java
  5. java db2jdbc4

If the output looks good, then exit from the Unix shell prompt and return to ISPF.


Java program execution using JCL

Execute the db2jdbc4 java program using JCL which writes output to Z#####.P3.OUTPUT(#08)

tso submit 'zos.public.jcl(db2jdbc4)'

Feel free to check the JCL job for successful completion and the Z#####.P3.OUTPUT(#08) for the output previously displayed when java program was executed from Unix shell prompt.


Next: Challenge #09