JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1

The Type 4 driver provides for user name and password encryption before it is sent to MXCS. The
password is encrypted with a proprietary algorithm provided by the MXCS product. For information
on secure JDBC connection using NonStop SSL, see “Providing a secure JDBC connection using
NonStop SSL” (page 108)
Connecting to SQL/MX
A Java application can obtain a JDBC connection to NonStop SQL/MX in two ways:
By using the DataSource interface (the preferred method)
By using the DriverManager class
Connecting with the DataSource Interface
“Overview of Deploying DataSource Objects (page 21)
“DataSource Object Properties (page 22)
“Programmatically Creating an Instance of the DataSource Class (page 22)
“Programmatically Registering the DataSource Object (page 22)
“Retrieving a DataSource Instance by using JNDI and to the Data Source” (page 23)
“Specifying the Properties File that Configures the Data Source (page 23)
The javax.sql.DataSource interface is the preferred way to establish a connection to the
database because this interface enhances the application portability. Portability is achieved by
allowing the application to use a logical name for a data source instead of providing driver-specific
information in the application. A logical name is mapped to a javax.sql.DataSource object
through a naming service that uses the Java Naming and Directory Interface (JNDI). Using this
DataSource method is particularly recommended for application servers.
Observe that two types of data sources interact here as described under Data Sources.
When an application requests a connection by using the getConnection method in the
DataSource, the method returns a Connection object. A DataSource object is a factory for
Connection objects. An object that implements the DataSource interface is typically registered
with a JNDI service provider.
Overview of Deploying DataSource Objects
Before an application can connect to a DataSource object, typically the system administrator
deploys the DataSource object so that the application programmers can start using it.
Data source properties are usually set by a system administrator using a GUI tool as part of the
installation of the data source. Users to the data source do not get or set properties. Management
tools can get at properties by using introspection.
Tasks involved in creating and registering a database object are:
1. Creating an instance of the DataSource class.
2. Setting the properties of the DataSource object.
3. Registering the DataSource object with a naming service that uses the Java Naming and
Directory Interface (JNDI) API.
An instance of the DataSource class and the DataSource object properties are usually set by
an application developer or system administer using a GUI tool as part of the installation of the
data source. If you are using an installed data source, skip to topic Programmatically Creating an
Instance of a DataSource Object.
The subsequent topics show an example of performing these tasks programmatically.
For more information about using data sources, see the JDBC Tutorial: Chapter 3- Advanced Tutorial
http://java.sun.com/developer/Books/JDBCTutorial/index.html or other information available in
the field.
Connecting to SQL/MX 21