![]() |
|
Use the JDBC API SQLException class to handle errors in your Java program. The Informix-specific com.informix.jdbc.Message class can also be used outside a Java program to retrieve the Informix error text for a given error number.
Whenever an error occurs from either Informix JDBC Driver or the database server, an SQLException is raised. Use the following methods of the SQLException class to retrieve the text of the error message, the error code, and the SQLSTATE value:
All Informix JDBC Driver errors have error codes of the form -79XXX, such as -79708 Method can't take null parameter.
For a list of Informix database server errors, refer to Informix Error Messages. You can find the on-line version of this guide at http://www.informix.com/answers.
The following example from the SimpleSelect.java program shows how to use the SQLException class to catch Informix JDBC Driver or database server errors using a try-catch block:
Informix provides the class com.informix.jdbc.Message for retrieving the Informix error message text based on the Informix error number. To use this class, call the Java interpreter java directly, passing it an Informix error number, as shown in the following example:
The example returns the message text for Informix error 100:
A positive error number is returned if you specify an unsigned number when using the com.informix.jdbc.Message class. This differs from the finderr utility, which returns a negative error number for an unsigned number.