Program Preparation For Java Routines; Preparation Of Java Routines With No Sqlj Clauses - IBM DB2 Manual

Table of Contents

Advertisement

Program preparation for Java routines

The program preparation process for Java routines varies, depending on whether
the routines contain SQLJ clauses.
The following topics contain detailed information on program preparation for Java
routines.

Preparation of Java routines with no SQLJ clauses

Java routines that contain no SQLJ clauses are written entirely in JDBC. There are
three methods for preparing Java routines with no SQLJ statements.
Those methods are:
v Prepare the Java routine to run from a JAR file. Running Java routines from JAR
v Prepare the Java routine with no JAR file.
v Use DB2 Developer Workbench to prepare the routine.
Preparing Java routines with no SQLJ clauses to run from a JAR
file
The recommended method of running Java routines is to run them from a JAR file.
The program preparation process for Java routines that contain no SQLJ clauses
and run from a JAR file includes compiling the program, creating the JAR file,
defining the JAR file and the routine to DB2, and granting the appropriate
privileges.
The steps in the process are:
1. Run the javac command to compile the Java program to produce Java
2. Run the jar command to collect the class files that contain the methods for
3. Call the INSTALL_JAR stored procedure to define the JAR file to DB2.
4. If the installed JAR references classes in other installed JARs, call the
5. If another user defines the routine to DB2, execute the SQL GRANT USAGE
6. Execute the SQL CREATE PROCEDURE or CREATE FUNCTION statement to
7. Execute the SQL GRANT statement to grant the EXECUTE privilege on the
Related tasks
"Program preparation for SQLJ programs" on page 183
Related reference
"db2sqljbind - SQLJ profile binder" on page 407
files is recommended.
You can use this method regardless of whether the routine is in a JAR file.
bytecodes.
your routine into a JAR file. See 'Creating JAR files for Java routines" for
information on creating the JAR file.
SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path
that the JVM searches to resolve those class references.
ON JAR statement to grant the privilege to use the JAR file to that user.
define the routine to DB2. Specify the EXTERNAL NAME parameter with the
name of the JAR that you defined to DB2 in step 3.
routine to the appropriate users.
Related concepts
"Program preparation for JDBC programs" on page 183
Chapter 6. Preparing and running JDBC and SQLJ programs
187

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents