NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)
Connection to SQL/MX
A Java application can obtain a JDBC connection to SQL/MX in two ways:
Using the DriverManager class●
Using the DataSource implementation●
Connection Using the DriverManager Class
This is the traditional way to establish a connection to the database. The DriverManager class works with the
Driver interface to manage the set of drivers loaded. When an application issues a request for a connection using the
DriverManager.getConnection method and provides a URL, the DriverManager is responsible for
finding a suitable driver that recognizes this URL and obtains a database connection using that driver.
com.tandem.sqlmx.SQLMXDriver is the JDBC/MX driver class that implements the Driver interface. The
application can load the JDBC/MX driver in one of the following ways:
Specifying the JDBC/MX driver class in the -Djdbc.drivers option in the command line●
Using the Class.ForName method within the application●
Adding the JDBC/MX driver class to the jdbc.drivers property within the application●
The DriverManager.getConnection method accepts a string containing a JDBC URL. The JDBC URL for the
JDBC/MX driver is jdbc:sqlmx:.
Connection Using the DataSource Implementation
The DataSource interface, introduced in the JDBC 2.0 optional package, is the preferred way to establish a
connection to the database because it enhances the application portability. The JDBC/MX driver implements the
DataSource interface and returns a connection object when an application requests a connection using the
getConnection method in the DataSource interface.