JDBC Type 4 Driver 1.1 Programmer's Reference
Note: There is no secure wire communication such as SSL provided for the communication between Type 4 driver and the
MXCS server.
How to Make a Connection 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●
Connection by Using the DataSource Interface
Overview of Tasks to Deploy DataSource Objects
DataSource Object Properties
Programmatically Creating an Instance of the DataSource Class
Programmatically Registering the DataSource Object
Retrieving a DataSource Instance by using JNDI and to the Data Source
Specifying the Properties File that Configures the Data Source
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 Tasks to Deploy 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:
Creating an instance of the DataSource class.1.
Setting the properties of the DataSource object.2.
Registering the DataSource object with a naming service that uses the Java Naming and Directory Interface (JNDI)
API.
3.
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.