Question & Answer
Question
How to query Db2 for z/OS data source using Federation Server through JDBC driver?
Cause
Customers want to use Federation server connect to Db2 for z/OS through JDBC driver.
Answer
To configure a federation to access Db2 for z/OS data source through JDBC wrapper, you must provide the federation with information about the data sources and objects that you want to access. Then create wrapper, server, user mapping and nickname about the tables on remote Db2 for z/OS data source.
Before you begin
Check the driver db2jcc4.jar in the path $/INSTANCE_HOME/sqllib/java.
1. Enable Federation server and restart Db2.
# db2 update dbm cfg using federated YES
# db2stop force
# db2start
2. Test the connection to the Db2 for z/OS data source and verify the service is started correctly.
telnet <db2_zos_ip> <port>
If the connection is successful, you receive the following similar output from the command.
# telnet 9.125.72.122 480
Trying 9.125.72.122...
Connected to 9.125.72.122.
3. Create wrapper, server, user mapping, nickname, and query the nickname.
# connect to testdb
# create wrapper "wrapper1" library 'libdb2rcjdbc.so' options(db2_fenced 'y')
# CREATE SERVER server1 TYPE db2zos WRAPPER "wrapper1" OPTIONS (DRIVER_CLASS 'com.ibm.db2.jcc.DB2Driver' ,DRIVER_PACKAGE '/home/db2inst1/sqllib/java/db2jcc4.jar' , URL 'jdbc:db2://9.125.72.122:480/LOCDB11')
# create user mapping for user server server1 options(REMOTE_AUTHID 'J15USR4',REMOTE_PASSWORD 'password')
# CREATE NICKNAME nk1 FOR SERVER1."J15USR4".test1
# select * from nk1
col_1
--------------------------
1970-11-23-12.12.12.000000
1999-12-31-12.12.12.000000
2 record(s) selected.
Was this topic helpful?
Document Information
Modified date:
06 August 2020
UID
ibm11127583