Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 |
|
To handle exceptions, the Oracle JDBC drivers throw a java.sql.SQLException()
. Two types of errors can be returned. The first type, Oracle database errors, are returned from the Oracle database itself and consist of an error number and a text message describing the error. These errors are documented in the publication Oracle8i Error Messages.
The second type of error is returned by the JDBC driver itself. These messages consist of a text message, but do not have an error number. These messages describe the error and identify the method that threw the error.
You can return errors with these methods:
getMessage()
: returns the error message associated with the object that threw the exception
printStackTrace()
: prints this object name and its stacktrace to the specified print stream
This example uses both getMessage()
and printStackTrace()
to return errors.
catch(SQLException e); {System.out.println("exception: " + e.getMessage()); e.printStackTrace();}
The text of all error messages has been internationalized. That is, they are available in all of the languages and character sets supported by Oracle. These error messages are listed in Appendix A, "JDBC Error Messages".