SQL/MX 3.2 Guide to Stored Procedures in Java (H06.25+, J06.14+)
Writing SPJ Methods
HP NonStop SQL/MX Release 3.2 Guide to Stored Procedures in Java—691166-001
3-7
Accessing SQL/MP and SQL/MX Databases
to call another SPJ method, invoke the other Java method directly through Java
instead of using a CALL statement.
Accessing SQL/MP and SQL/MX Databases
SPJ methods that access an SQL/MP or SQL/MX database must be from a Java class
that uses JDBC/MX method calls. SQLJ is not supported on systems running H-series
RVUs.
Use of java.sql.Connection Objects on page 3-7
JDBC/MX-Based Java Method on page 3-7
Referring to Database Objects in an SPJ Method on page 3-8
Exception Handling on page 3-11
Use of java.sql.Connection Objects
NonStop SQL/MX supports default connection in the SPJ environment. Typically, the
default connection in an SPJ execution environment has a data source URL of
jdbc:default:connection. In NonStop SQL/MX, SPJ methods that create
java.sql.Connection have their data source URL as jdbc:sqlmx, which is specific to
NonStop SQL/MX and cannot be ported to other platforms. Therefore, Nonstop
SQL/MX supports default connections only in the SPJ environment and not outside it.
Each JDBC connection has its own SQL context and MXCMP server. If each
invocation of an SPJ method creates a new connection object and does not explicitly
close that connection, SQL/MX resources are consumed, and performance might
diminish. To avoid large numbers of MXCMP servers handling requests from the SPJ
environment:
Use the JDBC/MX implementation of connection pooling, where a cache of
physical database connections is assigned to a client session and reused.
Connection pooling is ON by default in the JDBC/MX driver and is therefore
enabled by default in an SPJ environment. For more information, see the JDBC
Driver for SQL/MX Programmer’s Reference.
Explicitly close each java.sql.Connection object when it is no longer needed
instead of relying on garbage collection. This action immediately releases SQL/MX
resources, including the MXCMP server, for that connection. For pooled
connections, closing the Connection object returns it to the pool of reusable
connections.
JDBC/MX-Based Java Method
A JDBC/MX-based Java method is from a Java program that contains SQL/MX
statements in JDBC/MX method calls. You can use this type of method to create an
SPJ that performs SQL operations on an SQL/MP or SQL/MX database.










