NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)
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();
}
catch (SQLException sqlex) {
System.out.println(sqlex);
// other error handling
res.close();
stmt.close();
sqlmpConn.close();
}
}
}
Compliance Information
The JDBC Driver for SQL/MP is not considered JDBC compliant for the following reasons:
CallableStatement is not supported because SQL/MP does not support stored procedures. The
CallableStatement class exists, but every method in the class throws an "unsupported method" exception.
●
Positioned updates and deletes are not supported because SQL/MP does not support these operations from dynamic SQL
(the underlying method the JDBC Driver for SQL/MP uses for accessing a database). However, positioned updates and
deletes can be performed from scrollable, insensitive result sets.
●
Multithreading is not completely supported in that invoking both executeQuery() and executeUpdates()
causes the entire JVM (not just the thread executing the SQL operation) to block.
●