SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

Registering SPJs in NonStop SQL/MX
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
4-8
Specifying the SPJ Method
Java Method Signature
Specifying the Java signature is necessary only when an SQL parameter of the SPJ
does not map by default to a Java wrapper class and when the SPJ method uses a
Java wrapper class instead of a Java primitive data type in its Java signature. See
Table 4-1, Mapping of SQL/MX Data Types to Java Data Types, on page 4-6.
Usually, if you do not specify the Java signature, the SQL data types map by default to
the correct Java data types. For example, this EXTERNAL NAME clause omits the
Java signature because the SQL parameters (NUMERIC and FLOAT) map by default to
the same Java data types (java.math.BigDecimal and double) as the parameters
of the underlying Java method:
EXTERNAL NAME 'Payroll.adjustSalary'
However, if you specify INT for an SQL parameter and the underlying SPJ method
uses java.lang.Integer, you must specify the Java signature in the EXTERNAL
NAME clause, as shown:
The Java signature is case-sensitive and must be placed within parentheses. The
signature must specify each of the parameter data types in the order that they appear
in the Java method definition within the class file. Each Java data type that
corresponds to an OUT or INOUT parameter must be followed by empty square
brackets ([ ]) to indicate that it is an array parameter:
CREATE PROCEDURE samdbcat.persnl.employeejob(IN empnum INT,
OUT jobcode INT)
EXTERNAL NAME 'Payroll.employeeJob(int,
java.lang.Integer[])'
An SPJ returns only one value to the first element of the array at index 0. An SPJ
cannot return an array of values to an OUT or INOUT parameter. For more information,
see Returning Output Values From the Java Method on page 3-2.
If you specify a Java signature string, NonStop SQL/MX verifies that the signature is a
valid mapping of the parameters of the specified method into Java data types. If the
signature is invalid, NonStop SQL/MX returns an error.
Even if you do not specify a Java signature string, NonStop SQL/MX generates a
compressed representation of the Java method signature and stores it in the TEXT
metadata table. The compressed signature conforms to the internal type signature
emitted by the javap tool and the -s option (for example, javap -s classfile).
VST020.vsd
EXTERNAL NAME 'Payroll.employeeJob(int, java.lang.Integer[])'
Java Method Signature
Java
Primitive
Data Type
Java
Wrapper
Class