INFORMIX
Informix JDBC Driver Programmer's Guide
Chapter 2: Programming with Informix JDBC Driver
Contents Index

Handling Errors

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.

Using the SQLException Class

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:

    Returns a description of the error. SQLException inherits this method from the java.util.Throwable class.

    Returns an integer value that corresponds to the Informix database server or Informix JDBC Driver error code.

    Returns a string that describes the SQLState. The string follows the X/Open SQLState conventions.

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 the following Web site:

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:

Retrieving Informix Error Message Text

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:




Informix JDBC Driver Programmer's Guide, Version 1.22
Copyright © 1998, Informix Software, Inc. All rights reserved.