IBM DB2 Manual page 205

Table of Contents

Advertisement

2. Run the db2sqljcustomize command to produce serialized profiles that are
customized for DB2 for z/OS and DB2 packages.
3. Run the jar command to package the class files that contain the methods for
your routine, and the profiles that you generated in step 2 into a JAR file. See
"Creating JAR files for Java routines" for information on creating the JAR file.
4. Call the INSTALL_JAR stored procedure to define the JAR file to DB2.
5. If the installed JAR references classes in other installed JARs, call the
SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path
that the JVM searches to resolve those class references.
6. If another user defines the routine to DB2, execute the SQL GRANT USAGE
ON JAR statement to grant the privilege to use the JAR file to that user.
7. Execute the SQL CREATE PROCEDURE or CREATE FUNCTION statement to
define the routine to DB2. Specify the EXTERNAL NAME parameter with the
name of the JAR that you defined to DB2 in step 4.
8. Execute the SQL GRANT statement to grant the EXECUTE privilege on the
routine to the appropriate users.
The following example demonstrates how to prepare a Java stored procedure that
contains SQLJ clauses for execution from a JAR file.
1. On z/OS UNIX System Services, run the sqlj command to translate and
compile the SQLJ source code.
Assume that the path for the stored procedure source program is
/u/db2res3/s1/s1sal.sqlj. Change to directory /u/db2res3/s1, and issue this
command:
sqlj s1sal.sqlj
After this process completes, the /u/db2res3/s1 directory contains these files:
s1sal.java
s1sal.class
s1sal_SJProfile0.ser
2. On z/OS UNIX System Services, run the db2sqljcustomize command to
produce serialized profiles that are customized for DB2 for z/OS and to bind
the DB2 packages for the stored procedure.
Change to the /u/db2res3 directory, and issue this command:
db2sqljcustomize -url jdbc:db2://mvs1:446/SJCEC1 \
-user db2adm -password db2adm \
-bindoptions "EXPLAIN YES" \
-collection ADMCOLL \
-rootpkgname S1SAL \
s1sal_SJProfile0.ser
After this process completes, s1sal_SJProfile0.ser contains a customized
serialized profile. The DB2 subsystem contains these packages:
S1SAL1
S1SAL2
S1SAL3
S1SAL4
3. On z/OS UNIX System Services, run the jar command to package the class
files that you created in step 1 and the customized serialized profile that you
created in step 2 into a JAR file.
Change to the /u/db2res3 directory, and issue this command:
jar -cvf s1sal.jar s1/*.class s1/*.ser
After this process completes, the /u/db2res3 directory contains this file:
Chapter 6. Preparing and running JDBC and SQLJ programs
189

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents