JDBC Driver for SQL/MP 3.0

ResultSet rs = stmt.executeQuery("drop table usertable");
}
catch (SQLException sqlex) {
// error handling
}
This example is like the preceding example except that it declares the statement outside the try-catch block. If
executeQuery() throws an exception, the statement is not left dangling.
Statement stmt;
ResultSet rs;
try {
stmt = conn.createStatement();
ResultSet rs
= stmt.executeQuery("drop table usertable");
}
catch (SQLException sqlex) {
// error handling
}
finally {
stmt.close();
}
Sample SQL/MP Program
This 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));
}