Handling SQLExceptions

Many of the methods in the java.sql classes throw SQLException upon failure. Host Integrator takes advantage of SQLException to chain multiple exceptions together. Use the method getNextException to get the next exception in the chain, stopping when this method returns null. For example, to print the full exception chain starting with the top level SQLException, use the following Java method:

void printException(Exception e) {
    Class cl= e.getClass();
    if(cl.getName().compareTo("java.sql.SQLException") == 0) {
        SQLException SQLEx = (SQLException) e;

        System.out.println("Exception chain:");
        while(SQLEx != null) {
            System.out.println("Code:"+SQLEx.getErrorCode()+" -- "+SQLEx.getMessage());
            SQLEx = SQLEx.getNextException();
        }
    }
    else {
        System.out.println("Exception: "+e.getMessage());
    }
}

The error code number that Host Integrator supplies with a SQLException signifies the class of Host Integrator exception that occurred.



Error Code Description
001 ApptrieveException - the top level exception indicating the JDBC method that failed.
101 ChannelException - provides information on errors that occur in the network interactions with the Host Integrator Server.
201 DeadSessionException - class provides information on errors that occur at the Host Integrator Server resulting from fatal errors that occur between the Host Integrator Server and the host's terminal session. The condition is not recoverable.
301 MarshallerException - provides information on errors that occur in the network type marshaller.
401 ModelDataException - class provides information on errors that occur at the Host Integrator Server resulting from bad arguments passed in method calls.
501 ModelDefException - provides information on errors that occur at the Host Integrator Server resulting from bad arguments passed in method calls.
601 ServerException - provides information on errors that occur at the Host Integrator Server.
701 TerminalException - provides information on errors that occur at the Host Integrator Server resulting from errors that originate on the host's terminal session.
801 TimeoutException - relays method call timeouts to the user.
901 UserException - provides information on errors that occur at the Host Integrator Server dealing with error conditions defined by the model author.

You can retrieve the error code for SQLException using the getErrorCode() method.

 

 

  Attachmate