NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)
No suitable driver Error
The error message No suitable driver means that the Java Virtual Machine (JVM) could not load the JDBC
driver that the program needs. For instructions on loading JDBC drivers, see Loading a Driver.
Data Truncation
Data truncation occurs without warning. To prevent data truncation, use Java data types that are large enough to hold the
SQL data items that are to be stored in them (see Compatible Java and SQL/MP Data Types).
Dangling Statements
SQL/MP drivers track all statements within a connection, but when an exception occurs, Java's garbage collection
feature might prevent a driver from immediately closing an open statement. A statement that is left dangling inside a
connection could cause unexpected results.
To avoid dangling statements, do the following:
Create statements outside try-catch blocks.●
Close statements when they are no longer needed.●
In the following example, if executeQuery() throws an exception, the statement inside the try-catch block might
be left dangling.
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("drop table usertable");
}
catch (SQLException sqlex) {
// error handling
}
The following example is like the preceding example except that it declares the statement outside the try-catch block.
If executeQuery() throws an exception, the statement will not be 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();
}