Binding SQLJ applications to access multiple database servers
After you prepare an SQLJ program to run on one Db2 database server, you might want to port that application to other environments that access different database servers. For example, you might want to move your application from a test environment to a production environment.
Procedure
The general steps for enabling access of an existing SQLJ application to additional database servers are:
Example
db2sqljcustomize -url jdbc:db2://system1.svl.ibm.com:8000/ZOS1
-user user01 -password mypass
-rootPkgName WRKSQLJ
-qualifier WRK1
-collection MYCOL1
-bindoptions "CURRENTDATA NO QUALIFIER WRK1 "
-staticpositioned YES WrkTraceTest_SJProfile0.ser
- Run Db2 BIND with COPY to
copy each of the packages (one for each isolation level) from the
ZOS1 system to the ZOS2 system:
BIND PACKAGE (ZOS2.MYCOL2) OWNER(USER01) QUALIFIER(WRK2) - COPY(MYCOL.WRKSQLJ1) CURRENTDATA(NO) BIND PACKAGE (ZOS2.MYCOL2) OWNER(USER01) QUALIFIER(WRK2) - COPY(MYCOL.WRKSQLJ2) CURRENTDATA(NO) BIND PACKAGE (ZOS2.MYCOL2) OWNER(USER01) QUALIFIER(WRK2) - COPY(MYCOL.WRKSQLJ3) CURRENTDATA(NO) BIND PACKAGE (ZOS2.MYCOL2) OWNER(USER01) QUALIFIER(WRK2) - COPY(MYCOL.WRKSQLJ4) CURRENTDATA(NO)
- Run the db2sqljbind command to create Db2 packages on ZOS2 from the serialized profile
on ZOS1:
db2sqljbind -url jdbc:db2://system2.svl.ibm.com:8000/ZOS2 -user user01 -password mypass -bindoptions "COLLECTION MYCOL2 QUALIFIER WRK2" -staticpositioned YES WrkTraceTest_SJProfile0.ser
After you bind the packages, you need to ensure that when the application runs, the Db2 database server at ZOS2 can find the packages. The collection ID in the serialized profile is MYCOL1, so the Db2 database server looks in MYCOL1 for the packages. When you run the application against the ZOS2 system, you need to access packages in MYCOL2.
- Specify
"MYCOL1.*,MYCOL2.*"
in the pkListDataSource
property:pkList = MYCOL1.*,MYCOL2.*
- Bind a plan for the application that includes the packages in
MYCOL2 and the IBM Data Server Driver for JDBC and
SQLJ packages:
Then specify WRKSQLJ in the planNameBIND PLAN(WRKSQLJ) PKLIST(MYCOL1.*,MYCOL2.*,JDBCCOL.*)
DataSource
property:planName = WRKSQLJ
For applications
that use IBM Data Server Driver for JDBC and
SQLJ type 4 connectivity,
specify "MYCOL1,MYCOL2"
in the currentPackagePath DataSource
property.