Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


Error Handling

The Class SQLException

The SQLException class provides information relating to database errors. Details include a textual description of the error, an SQLState string, and an error code. There may be a number of SQLException objects for a failure.

 try {
 } catch(SQLException sqe) {
     SQLException stk;
     stk = sqe;   // Save initial exception for stack trace 
     System.err.println("\n*** SQLException:\n");
     while (sqe != null) {
         System.err.println("Message:     " + sqe.getMessage());
         System.err.println("SQLState:    " + sqe.getSQLState());
         System.err.println("NativeError: " + sqe.getErrorCode());
         sqe = sqe.getNextException();

The Class SQLWarning

The SQLWarning class provides information relating to database warnings. The difference between warnings and exceptions is that warnings, unlike exceptions, are not thrown.

The getWarnings method of the appropriate object (Connection, Statement or ResultSet) is used to determine whether warnings exist.

Warning information can be retrieved using the same mechanisms as in the SQLException example above but with the method getNextWarning retrieving the next warning in the chain:

 con = DriverManager.getConnection(url);
 private static boolean checkSQLWarning( SQLWarning sqw ) 
 throws SQLException {
     boolean rc = false;
     if (sqw != null) {
         rc = true;
         System.err.println("\n*** SQLWarning:\n");
         while (sqw != null) {
             System.err.println("Message:     " + sqw.getMessage());
             System.err.println("SQLState:    " + sqw.getSQLState());
             System.err.println("NativeError: " + sqw.getErrorCode());
             sqw = sqw.getNextWarning();
     return rc;

Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
Mimer SQL Documentation TOC PREV NEXT INDEX