NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)
Legend
JDBC driver class1.
Java Virtual Machine (JVM)2.
JDBC Driver Manager3.
SQL/MP database4.
Oracle database5.
JavaDB database6.
Specifying the JDBC Driver Class on the java Command Line
To specify the JDBC driver class on the java command line, use the -Djdbc.drivers option. For example, the
following java command loads the SQL/MP driver, whose class name is com.tandem.sqlmp.SQLMPDriver:
java -Djdbc.drivers=com.tandem.sqlmp.SQLMPDriver
To specify multiple JDBC driver classes on the java command line, separate them with semicolons. For example, the
following java command loads the SQL/MP driver and a driver whose class name is
com.javaco.purejavajdbc.Driver:
java -Djdbc.drivers=com.tandem.sqlmp.SQLMPDriver;com.javaco.purejavajdbc.Driver
Adding the JDBC Driver Class to the jdbc.drivers Property
To add the JDBC driver class to the jdbc.drivers property, follow these steps:
Create a new Properties object using this command:
Properties prop=new Properties();
1.
Add the JDBC driver class to the jdbc.drivers property using this command:
prop.put("jdbc.drivers","driver_class_name[;driver_class_name]");
2.
Set the system properties using this command:
System.setProperties(prop);
3.
The first call to a JDBC DriverManager method will load the driver or drivers.
The following code adds the SQL/MP driver and the JDBC driver whose class name is
com.javaco.purejavajdbc.Driver to the jdbc.drivers property:
Properties prop=new Properties();
prop.put("jdbc.drivers","com.tandem.sqlmp.SQLMPDriver; \
> com.javaco.purejavajdbc.Driver");
System.setProperties(prop);
Loading the JDBC Driver Class Directly Into the JVM
To load the JDBC driver class directly into the JVM, use the Class.forName() method.
The following code loads the SQL/MP driver and the JDBC driver whose class name is
com.javaco.purejavajdbc.Driver directly into the JVM:
Class.forName("com.tandem.sqlmp.SQLMPDriver");
Class.forName("com.javaco.purejavajdbc.Driver");