SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)

When an SQL/MX application issues a CALL statement, a class loader in the SPJ environment uses
the class path to locate and load Java classes outside the external path of the SPJ method. For
more information, see Class Loaders in an SPJ Environment (page 28).
When an SQL/MX application issues a CREATE PROCEDURE statement, the JVM resolves references
to other Java classes in the signature of the SPJ method but not inside the body of the SPJ method.
For example, the JVM might encounter a user-defined exception class in the throws clause of the
signature, as shown:
public static void lowerPrice()
throws pkg.subpkg.myException
If the user-defined exception class exists outside the external path, the location of the exception
class must be listed in the class path.
To set the class path in an SPJ environment, use these approaches:
Setting the Class Path by Using UDR_JAVA_OPTIONS (page 44)
Setting the CLASSPATH Environment Variable (page 45)
Each approach has a different scope and influence on CALL or CREATE PROCEDURE statements.
NOTE: To specify a nonstandard location of the JDBC/MX driver in the SPJ environment, use the
UDR extensions class path instead of the class path. Set the UDR extensions class path by using
the -Dsqlmx.udr.extensions option in the UDR_JAVA_OPTIONS default attribute. See Setting
the JDBC/MX Location (page 42).
Setting the Class Path by Using UDR_JAVA_OPTIONS
Use the UDR_JAVA_OPTIONS default attribute to set the class path in an SPJ environment for an
application or for all processes running on the node. The UDR_JAVA_OPTIONS default attribute
is particularly useful forNonStop ODBC/MX applications, which cannot use environment variables
set in the OSS or Guardian environment.
To set the class path by using the UDR_JAVA_OPTIONS default attribute, use this attribute value:
'-Djava.class.path=path1[{:path2}...]'
path1 and path2 are paths to JAR files or top-level directories where Java classes or package
directories exist. The paths must not include the package name.
CAUTION: NonStop SQL/MX maintains an SQL/MX UDR server process for each different set
of UDR_JAVA_OPTIONS in an application. The existence of multiple SQL/MX UDR server processes
might significantly affect system performance. Therefore, use UDR_JAVA_OPTIONS settings in your
application only when necessary. For more information, see SQL/MX UDR Server Process (page 25).
Scope of the Class Path in UDR_JAVA_OPTIONS
A class path set by a CONTROL QUERY DEFAULT statement affects the SPJ environment of
subsequent CALL or CREATE PROCEDURE statements. This class path setting persists until the
SQL/MX UDR server process, which hosts the SPJ environment, ends. For more information, see
SQL/MX UDR Server Process (page 25). For example, use a CONTROL QUERY DEFAULT statement
to set the class path before a CALL statement in an application:
CONTROL QUERY DEFAULT UDR_JAVA_OPTIONS
'-Djava.class.path=/usr/otherclasses:/usr/otherapps/myJar.jar';
CALL...
A class path inserted into the SYSTEM_DEFAULTS table affects all CALL or CREATE PROCEDURE
statements that run on the system. This class path setting persists until someone updates the
UDR_JAVA_OPTIONS attribute in the SYSTEM_DEFAULTS table. For example, insert a row in the
44 Getting Started