Before you can use a Java routine, you need to
define it to Db2.
About this task
Use the following procedure to manually define a Java
routine to Db2. If you use IBM®
Optim™ Development Studio, IBM
Optim Development Studio creates the definitions.
Procedure
-
Execute the CREATE PROCEDURE or CREATE FUNCTION statement to define the routine to Db2. To alter the routine definition, use the
ALTER PROCEDURE or ALTER FUNCTION statement.
- Optional:
If the routines are in JAR files, define the JAR files to Db2.
If the routines are in JAR files, it is recommended that you also define the JAR files to
Db2. Alternatively, you can include the
JAR file name in the CLASSPATH.
To define the JAR files to Db2:
- Use the SQLJ.INSTALL_JAR or SQLJ.DB2_INSTALL_JAR built-in stored procedure to define the JAR
files to Db2.
- After you have installed a JAR, if that JAR references classes in other
installed JARs, use the SQLJ.ALTER_JAVA_PATH stored procedure to specify the class resolution path
that the JVM searches to resolve those class references.
- To replace the JAR file, use the SQLJ.REPLACE_JAR or SQLJ.DB2_REPLACE_JAR stored procedure.
- To remove the JAR file, use the SQLJ.REMOVE_JAR or SQLJ.DB2_REMOVE_JAR stored procedure.
SQLJ.INSTALL_JAR, SQLJ, SQLJ.REPLACE_JAR, and SQLJ.REMOVE_JAR can be used only with the local
Db2 catalog. The other stored procedures
can be used with remote or local Db2
catalogs.