|
Q and A
Asked and Answered
I've been told I must use DB2 Connect from a Java application to extract data
from DB2 tables. One of the columns contains group data that is a DCLGEN and
looks like this:
G_AGCY_LOB_STAT_TB
(AGENCY LINE OF
BUSINESS STATUS TABLE)
05 G-AGCY-LOB-STATUS-TBL OCCURS 7 TIMES.
10 C-AGCY-LOB-STATUS PIC X.
10 D-AGCY-LOB-CLOSE PIC 9(7) COMP-3.
10 D-AGCY-LOB-FINAL-CLOSE PIC 9(7) COMP-3.
I need to access the data in the 6th occurrence of this table. Do I need to
worry about the Comp-3 data and how it will be interpreted by an ASCII machine?
Robert Catterall responds:
First of all, you don't necessarily need DB2 Connect to access DB2 data from a Java program. What
you need is a Java database connectivity (JDBC) driver. A JDBC driver ships with DB2 for OS/390, and
this driver is appropriate for use when the Java program in question is running on the same S/390
server as is the DB2 subsystem.
If the Java program is running on an ASCII-based system (for example, a Unix server), you have
network issues to deal with. In this case, IBM's DB2 Connect will provide you with both a JDBC
driver and the means to connect to a DB2 database located on a remote mainframe
system.
An alternative to DB2 Connect is the JDBC driver product available from HiT Software, Inc. I don't
think you need to worry about accessing the DB2 data which the COBOL program defines as COMP-3. That
COBOL definition maps to the DB2
DECIMAL
(or
NUMERIC
) data type.
Here's a link to an online version of the DB2 for OS/390 and z/OS Version 7 manuals:
http://www-3.ibm.com/software/data/db2/os390/v7books.html
. Look in the Application Programming Guide
and Reference for Java. In particular, see Table 1 in Chapter 2.4. Here, you will see the Java and
JDBC data types that map to the DB2
DECIMAL
data type. EBCDIC-to-ASCII translation (and vice versa)
is handled automatically when you access DB2 data using the Distributed Relational Database
Architecture (DRDA) protocol (and you will be using DRDA if you use DB2 Connect or the HiT Software
Type 4 JDBC driver). The
mainframe DB2 subsystem will have associated with it an EBCDIC code page,
and the ASCII-based requester system will have associated with it an ASCII code page. Standard
translate tables that map the one to the other will take care of the data translation for you.
See a
complete archive of reader/author Q&As
.
|