NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)
Sample SQL/MP Program
The following Java program connects itself to an SQL/MP database, sends a simple select statement to the database,
and processes the results.
import java.sql.*;
class sqlmpExample {
 // Load SQL/MP driver the first time, so you do not have to specify 
 // -Djava.drivers=com.tandem.sqlmp.SQLMPDriver when running java.
 static {
 try {
 Class.forName("com.tandem.sqlmp.SQLMPDriver");
 } catch (Exception ex) {}
 }
 public static void main(String argv[]) throws SQLException {
 String sqlmpURL = "jdbc:sqlmp:";
 // Use a valid table name from an existing database in the select statement.
 String sqlmpQuery = "select * from $VOL1.MYVOL.MYTAB";
 Statement stmt = null;
 Connection sqlmpConn = null;
 ResultSet res = null;
 try {
 // Try to connect to the SQL/MP database.
 sqlmpConn = DriverManager.getConnection(sqlmpURL);
 // Create an SQL statement object to submit SQL statements.
 stmt = sqlmpConn.createStatement();
 // Submit a query and create a ResultSet object.
 res = stmt.executeQuery(sqlmpQuery);
 // Display the results of the query.
 while(res.next()) {
 // Use get* methods appropriate to the columns in your table
 System.out.println("Col1 = " + res.getInt(1));
 System.out.println("Col2 = " + res.getString(2));
 System.out.println("Col1 = " + res.getInt(1));
 System.out.println("Col2 = " + res.getString(2));
 }
 res.close();
 stmt.close();
 sqlmpConn.close();
 }










