NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)

import java.sql.*;
...
Connection myConnection = DriverManager.getConnection("jdbc:sqlmptx:");
Pure Java Driver Example
In a Java program, the following code uses a pure Java driver, javaco, to create a connection (myConnection) between
the program and the database MyDatabase, which resides on the server MyServer:
import java.sql.*;
...
Connection myConnection = \
> DriverManager.getConnection("jdbc:javaco://MyServer/MyDatabase");
Passing SQL/MP Statements to a Database
When you have a connection between your Java program and an SQL/MP database, you can create an SQL statement and pass
it to the database, which will return a result. To create an SQL statement, use the connection's createStatement()
method. To pass the statement to the database, use the statement's executeQuery() method.
Each SQL statement runs as a waited operation, so executing an SQL statement within a thread blocks the JVM.
Note: If your SQL query includes the name of an SQL/MP table, fully qualify the table name in the query.
Otherwise, the volume and subvolume of the table name defaults to the current volume and subvolume.
In the following example, the result set is not cached, so each call to next() retrieves more information from the database:
import java.sql.*;
...
// Create a statement:
Statement myStatement = myConnection.createStatement();
// Pass the string argument directly to the database;
// results are returned in the ResultSet object, r:
ResultSet r = myStatement.executeQuery("SELECT * from $DATA1.DBASE.EMPL");
// Retrieve successive rows from the result set and
// print the first column of each row, which is a String:
while (r.next())
System.out.println("Column 1: " + r.getString(1));
For information about how database transactions are delimited, committed, and rolled back when using JDBC, see
Transactions.