Running the JDBC example

You can run the JDBC example to understand how to connect to Db2® by using the JDBC DriverManager interface.

Before you begin

A DB2CONN must be installed and active for the example to work.

About this task

This example uses the following Java classes and program:
Transaction Program Java™ class
J327 JDBC3270 JDBC3270

CICSDB2DynamicSQLExample

Procedure

Enter the J327 transaction in a terminal to run the example.
You receive the following messages on Task.out:
JDBC3270: Starting...
JDBC3270: Select Statement: SELECT * FROM EMP
EMPNO FIRSTNME MIDINIT LASTNAME WORKDEPT PHONENO HIREDATE JOB EDLEVEL SEX BIRTHDATE SALARY BONUS COMM
...
JDBC3270: Done

Results

CICS® performs the following processing:

  1. The transaction runs the main Java class that is defined in the PROGRAM resource JDBC3270.
  2. The Java program connects to Db2 and retrieves data from the Db2 MP Example table.