SQL/MX Programming Manual for Java
SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java—523726-003
3-7
Registering and Loading the JDBC/MX Driver
Explicitly Loading the JDBC/MX Driver
You must explicitly load the JDBC/MX driver for these types of connection context
constructors:
•
Connection context constructor that accepts a JDBC connection object:
CtxClassName(java.sql.Connection conn)
•
URL forms of the connection context constructor:
CtxClassName(String url, java.util.Properties info,
boolean autoCommit)
CtxClassName(String url, boolean autoCommit)
CtxClassName(String url, String user,
String password, boolean autoCommit)
For these connection contexts, you must register and load the JDBC/MX driver before
invoking the connection context constructor.
Add this code to an SQLJ program to load the JDBC/MX driver:
String driver = "com.tandem.sqlmx.SQLMXDriver";
Class.forName(driver);
The JDBC/MX driver is represented by "com.tandem.sqlmx.SQLMXDriver".
If you plan to use a connection context constructor that accepts a JDBC connection
object, create the JDBC connection after loading the JDBC/MX driver. Pass the JDBC
URL, jdbc:sqlmx:, to the getConnection() method of the
java.sql.DriverManager class:
Connection conn = DriverManager.getConnection("jdbc:sqlmx:");
To invoke connection context constructors, see Connection Contexts on page 3-8.
Note. Registering the JDBC/MX driver with the JDBC driver manager,
java.sql.DriverManager, is unnecessary if you explicitly load the driver with the
Class.forName() method.