IBM DB2 Manual page 181

Table of Contents

Advertisement

EXTERNAL NAME
'
(1)
JAR-name:
Notes:
1
For compatibility with DB2 Database for Linux, UNIX, and Windows, you can use an exclamation
point (!) after JAR-name instead of a colon.
2
For compatibility with previous versions of DB2, you can use a slash (/) after package-name instead
of a period.
|
|
statement. For Java routines, the argument of EXTERNAL NAME is a string
that is enclosed in single quotation marks. The EXTERNAL NAME clause for a
Java routine has the following syntax:
class-name.method-name
(2)
package-name .
Whether you include JAR-name depends on where the Java code for the routine
resides. If you create a JAR file from the class file for the routine (the output
from the javac command), you need to include JAR-name. You must create the
JAR file and define the JAR file to DB2 before you execute the CREATE
PROCEDURE or CREATE FUNCTION statement. If some other user executes
the CREATE PROCEDURE or CREATE FUNCTION statement, you need to
grant the USAGE privilege on the JAR to them.
If you use a JAR file, that JAR file must refer to classes that are contained in
that JAR file, are found in the CLASSPATH, or are system-supplied. Classes
that are in directories that are referenced in DB2_HOME or JCC_HOME, and
JAVA_HOME do not need to be included in the JAR file.
Whether you include (method-signature) depends on the following factors:
v The way that you define the parameters in your routine method
Each SQL data type has a corresponding default Java data type. If your
routine method uses data types other than the default types, you need to
include a method signature in the EXTERNAL NAME clause. A method
signature is a comma-separated list of data types.
v Whether you overload a Java routine
If you have several Java methods in the same class, with the same name and
different parameter types, you need to specify the method signature to
indicate which version of the program is associated with the Java routine.
If your stored procedure returns result sets, you also need to include a
parameter in the method signature for each result set. The parameter can be in
one of the following forms:
v java.sql.ResultSet[]
v An array of an SQLJ iterator class
You do not include these parameters in the parameter list of the SQL CALL
statement when you invoke the stored procedure.
Example: EXTERNAL NAME clause for a Java user-defined function: Suppose that
you write a Java user-defined function as method getSals in class S1Sal and
package s1. You put S1Sal in a JAR file named sal_JAR and install that JAR in
DB2. The EXTERNAL NAME parameter is :
EXTERNAL NAME 'sal_JAR:s1.S1Sal.getSals'
Example: EXTERNAL NAME clause for a Java stored procedure: Suppose that you
write a Java stored procedure as method getSals in class S1Sal. You put S1Sal
in a JAR file named sal_JAR and install that JAR in DB2. The stored procedure
(method-signature)
Chapter 5. Java stored procedures and user-defined functions
'
165

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents