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

Getting Started
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
2-22
Setting the Class Path
Setting the Class Path
The class path contains an ordered list of directories and JAR files in which to search
for Java class files. If an SPJ method refers to another application class (for example,
loads a class, creates an object of a class, or invokes a method of another class), the
other class must either be in the same external path location as the SPJ class or have
its location specified in the class path.
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 on page 1-15.
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 on page 2-22
Setting the CLASSPATH Environment Variable on page 2-24
Each approach has a different scope and influence on CALL or CREATE
PROCEDURE statements.
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 for NonStop 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:
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 on page 2-20.
'-Djava.class.path=path1[{:path2}...]'