EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #203 background imageLoading...
Page #203 background image
Related tasks
“Program preparation for SQLJ programs” on page 183
Related reference
“db2sqljbind - SQLJ profile binder” on page 407
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
files is recommended.
v Prepare the Java routine with no JAR file.
v Use DB2 Developer Workbench to prepare the routine.
You can use this method regardless of whether the routine is in a JAR file.
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
bytecodes.
2. Run the jar command to collect the class files that contain the methods for
your routine into a JAR file. See ’Creating JAR files for Java routines for
information on creating the JAR file.
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
SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path
that the JVM searches to resolve those class references.
5. 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.
6. 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 3.
7. Execute the SQL GRANT statement to grant the EXECUTE privilege on the
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

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability