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

Introduction
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
1-15
Multithreading in an SPJ Environment
Multithreading in an SPJ Environment
NonStop SQL/MX manages a single thread of execution within an SPJ environment,
even if the application that issues a CALL statement is a multithreaded Java
application. The CALL statements in a multithreaded application can execute in a
nonblocking manner, but the SPJ methods underlying those CALL statements execute
serially within a given SPJ environment.
In releases earlier than NonStop SQL/MX Release 2.0 ABJ SPRs, the SQL/MX UDR
server used the same nonblocking default mode as JDBC/MX. However, in SQL/MX
Release 2.0 ABJ SPRs and later, the SQL/MX UDR server sets the default behavior to
blocking mode. The SPJ environment is single-threaded, and blocking mode
decreases CPU path length and improves performance in the SPJ environment. You
can enable or disable nonblocking JDBC/MX in the SPJ environment by specifying
JVM startup options that contain the -Djdbcmx.sqlmx_nowait option. To specify
JVM startup options in the SPJ environment, see Controlling JVM Startup Options on
page 2-11. For information about nonblocking JDBC/MX, see the JDBC Driver for
SQL/MX Programmers Reference.
To support parallelism of CALL statements issued from a multithreaded application,
use different UDR_JAVA_OPTIONS settings for each CALL statement. The execution
of a CALL statement with a different UDR_JAVA_OPTIONS setting initiates a separate
SQL/MX UDR server process with its own SPJ environment. These SPJ environments
can process requests in parallel from a multithreaded application. For information
about setting the UDR_JAVA_OPTIONS default attribute, see Controlling JVM Startup
Options on page 2-11.
Class Loaders in an SPJ Environment
For system and extension classes, class loading in the SPJ environment is the same
as other Java environments. By default, SPJ classes, like other Java programs, use
the bootstrap class loader to load system classes, which are typically contained in the
rt.jar file and are the Java core API. SPJ classes use the extension class loader to
load classes from standard extension JAR files in the jre/lib/ext directory.
Class loading in the SPJ environment differs from other Java environments in that the
SQL/MX UDR server manages certain aspects of class loading. The SQL/MX UDR
server directs the system class loader, which typically manages an application’s class
path, to load classes in the SQL/MX language manager (mxlangman.jar), in the
JDBC/MX product file (jdbcMx.jar), and in the HP NonStop SQLJ product file
(sqlj.jar), as needed.
The SQL/MX UDR server also creates and assigns one SPJ class loader for each
distinct external path location, which you specify in the EXTERNAL PATH clause of a
CREATE PROCEDURE statement when registering an SPJ. The SPJ class loader
assigned to an external path becomes responsible for loading all SPJ classes in a
Caution. NonStop SQL/MX does not prevent SPJ methods from spawning other threads.
Doing so is not advised and can lead to unpredictable results.