JDBC Driver for SQL/MP 3.0
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, this 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, this
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:
1. Create a new Properties object using this command:
Properties prop=new Properties();
2. Add the JDBC driver class to the jdbc.drivers property using this command:
prop.put("jdbc.drivers","driver_class_name[;driver_class_name]");
3. Set the system properties using this command:
System.setProperties(prop);
The first call to a JDBC DriverManager method loads the driver or drivers.
This 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.
This 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");
Connecting a Program to a Database
After a driver is loaded, you can use it to connect your Java program to a database by passing the URL of the database
to the DriverManager.getConnection() method.
You do not need to specify a username and a password to connect to an SQL/MP database.