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

Writing SPJ Methods
HP NonStop SQL/MX Guide to Stored Procedures in Java540433-003
3-6
Null Input and Output
must have the character string data type, CHAR or VARCHAR, and be declared with
the IN mode.
If you specify the optional Java signature in the EXTERNAL NAME clause of the
CREATE PROCEDURE statement, the signature must be (java.lang.String
[]). For more information about creating an SPJ, see the Using the CREATE
PROCEDURE Statement on page 4-2.
Null Input and Output
You can pass a null value as input to or output from an SPJ method, provided that the
Java data type of the parameter supports nulls. Java primitive data types do not
support nulls. However, Java wrapper classes that correspond to primitive data types
do support nulls. If a null is input or output for a parameter that does not support nulls,
NonStop SQL/MX raises an error condition.
To anticipate null input or output for your SPJ, use Java wrapper classes instead of
primitive data types in the method signature.
For example, this Java method uses a Java primitive data type in its signature where
no null values are expected:
public static void employeeJob(int empNum,
Integer[] jobCode)
This Java method also uses a Java wrapper class in its signature to anticipate a
possible returned null value:
public static void employeeJob(int empNum,
Integer[] jobCode)
Static Java Variables
To ensure that your SPJ method is portable, you should avoid declaring static variables
in the method. NonStop SQL/MX does not ensure the scope and persistence of static
Java variables.
Consider these drawbacks to using static variables in your SPJ method:
If an SQL/MX UDR server crashes, the calling application receives a new SQL/MX
UDR server and a new SPJ environment, including new copies of all static
variables initialized in that server. For more information, see SQL/MX UDR Server
Process on page 1-12.
When application classes contain static variables, NonStop SQL/MX does not
ensure that exactly one copy of those static variables is in a given SQL/MX UDR
server process or SPJ environment. For more information, see Class Loaders in an
SPJ Environment on page 1-15.