SQL/MX Programming Manual for Java
SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java—523726-003
3-6
Registering and Loading the JDBC/MX Driver
sqlj.runtime.ExecutionContext). To import this package, code this import
statement at the beginning of an SQLJ source file:
import sqlj.runtime.*;
For more information about the sqlj.runtime package, see Appendix B, SQLJ
Runtime Package.
Registering and Loading the JDBC/MX Driver
The JDBC Driver for SQL/MX (JDBC/MX) enables a Java program to use SQL/MX to
access an SQL/MP or SQL/MX database. For more information about JDBC/MX, see
the JDBC Driver for SQL/MX Programmer’s Reference.
SQLJ programs use a connection context—explicitly or implicitly—to associate SQL
statements with a database, and the connection context involves a JDBC connection.
Your choice of implicitly or explicitly loading the JDBC/MX driver depends on the type
of connection context constructors that you invoke in the SQLJ program. Explicitly
loading the JDBC/MX driver is required for some types of connection contexts. For
more information, see Connection Contexts on page 3-8.
Implicitly Loading the JDBC/MX Driver
You are not required to load the JDBC/MX driver explicitly for these types of
connection contexts:
•
Implicit connection context
In SQLJ supported by SQL/MX, an internal method creates an implicit, default
connection. This method loads the JDBC/MX driver and creates a JDBC
connection by using jdbc:sqlmx:. Each invocation of this method creates an
additional JDBC connection.
•
Explicit default connection context that uses one of these methods:
CtxClassName getDefaultContext()
setDefaultContext(CtxClassName ctx)
These connection class methods either return or set the implicit, default connection
context, which uses the default connection.
•
Connection context constructor that accepts a connection context:
CtxClassName(ConnectionContext other)
The code that creates the input connection context requires the JDBC/MX driver to
be loaded already, either implicitly for the default connection context or explicitly.
Note. Currently, SQL/MX does not support a DataSource connection for an SQLJ program.