Application Development Using Java
Part Three - Challenge #05


The z System hardware architecture hosting z/OS has capabilities that is perhaps the absolute best platform for Java and JVMs

These capabilities include

  • zIIP - dedicated processors for Java workload
  • SIMD - Single Instruction, Multiple Data
  • SIMT - Single Instruction, Multiple Threads
  • SMT - Simulatenous Multithreading
  • CPACF - CP Assist for Cryptographic Function

Java 8 exploits z Systems new SIMD vector hardware instructions for the Java libraries and numerous frequently used functions. Benchmarks exploiting SIMD vector hardware instructions improved by between 2X and 60X.

In the z/OS environment, the unix shell, JCL, and middleware such as CICS is available to execute Java where Java APIs exist to read from and write to any combination of z/OS data sources.

Your challenge:

While Java can read and write to any z/OS data source, a very powerful Java API is the ability to read and write to relational database tables. A Java driver, (JDBC - Java Database Connectivity), enables this capability.

You are given a Java program that successfully connects to DB2 for z/OS relational database table, executes a SQL statement to count the number unique world currencies, then prints the count. The challenge is to modify this Java program to also count the number of unique world universities, then print counts for both unique world currencies and unique world universities

The following tips apply to REXX and COBOL programming languages and equally apply to those with very little Java specific experience:

Programming languages have:

  1. well defined reserved words with documented behavior to accomplish a task
  2. rules for declaring variables to store characters, numbers, etc.
  3. well defined arithmetic operands and structures for formulas and boolean logic
  4. well defined string manipulation functions
  5. repeatable coding techniques where experience comes from recognizing and reusing specific coding techniques, then finally developing capability to recognize and reuse superior coding techniques

A few needed Java coding facts for accomplishing this challenge

  • Anything following // on a line is a comment. The comments are helpful.
  • Java curly braces '{' some_code '}' identifies a "section" of code with a limited scope. This applies to the 'while' statement that follows the SQL statement execution where that 'while' code is limited to each line returned from the associated SQL statement.
  • Because variables 'rs1' and 'sql1' are used to execute and store result set from the WC.CURRENCY table, use different variables, such as 'rs2' and 'sql2', to execute and store result set from the world universities table, WC.UNIV.

Review Java code that will need to be modified

  • Edit cc#####.source(world)
  • Review world Java source code considering tips above
  • Copy the Java code to your UNIX home directory using JCL by entering tso submit jcl(copyjava)on this source code edit primary command line.
  • SSH Login to z/OS UNIX System Services (USS) shell prompt. Note: Keep your TN3270 edit session active.
  • From USS shell prompt:
    1. javac
    2. java worldFacts
  • Observe output written to USS session:
    1. Number of World Currencies = 181
    2. Number of World Universites =

The objective of this challenge is for the Java program to write a count for both Number of World Currencies and Number of World Universites. The DB2 for z/OS relational table with World Universites is WC.UNIV.

Modify Java code to include count for Number of World Universities =

  • Edit cc#####.source(world) using TN3270 session
  • Modify world Java source code considering tips above
  • save ,then tso submit jcl(copyjava)
  • From USS shell prompt:
    1. javac
    2. java worldFacts
  • If unsuccessful, then correct cc#####.source(world) using TN3270 edit session
  • If Number of World Universites = has the count from the table, then
    1. java worldFacts >> world.output
    2. From TN3270 sessiontso submit jcl(copyfile)
  • Review P3.OUTPUT(#05) contains output with both counts

In the event, original copy of Java source is needed

  • Edit cc#####.source(world)
  • d99 on line 1 and copy 'zos.public.p3.source(world)'

Next: Challenge #06