![]() |
Controlling Cloudscape Application Behavior
|
Reference Manual |
Working with Cloudscape SQLExceptions in an ApplicationJDBC generates exceptions of the type java.sql.SQLException. To see the exceptions generated by Cloudscape, retrieve and process the SQLExceptions in a catch block. Information Provided in SQLExceptionsCloudscape provides the message, SQLState values, and error codes. Use the getSQLState and getMessage methods to view the SQLState and error messages. Use getErrorCode to see the error code. The error code defines the severity of the error and is not unique to each exception. The severity levels are described in COM.cloudscape.types.JBMSExceptionSeverity. In addition, a single error can generate more than one SQLException. Use a loop and the getNextException method to process all SQLExceptions in the chain. In many cases, the second exception in the chain is the pertinent one. The following example is taken from the sample application: catch (Throwable e) { System.out.println("exception thrown:"); errorPrint(e); } static void errorPrint(Throwable e) { if (e instanceof SQLException) SQLExceptionPrint((SQLException)e); else System.out.println("A non-SQL error: " + e.toString()); } static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); System.out.println("SQLState: " + (sqle).getSQLState()); System.out.println("Severity: " + (sqle).getErrorCode()); System.out.println("Message: " + (sqle).getMessage()); sqle.printStackTrace(); sqle = sqle.getNextException(); } } See also Chapter 5, "Cloudscape Exception Messages and SQL States", in the Cloudscape Reference Manual. Applications should also check for and process java.sql.SQLWarnings, which are processed in a similar way. Cloudscape issues an SQLWarning if the create=true attribute is specified and the database already exists. |
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |