8.6 How Oracle JVM Handles Exceptions
Java exceptions are objects and have a naming and inheritance hierarchy. As a result, you can substitute a subexception, that is, a subclass of an exception class, for its superexception, that is, the superclass of an exception class.
All Java exception objects support the toString()
method, which returns the fully qualified name of the exception class concatenated to an optional string. Typically, the string contains data-dependent information about the exceptional condition. Usually, the code that constructs the exception associates the string with it.
When a Java stored procedure runs a SQL statement, any exception thrown is materialized to the procedure as a subclass of java.sql.SQLException
. This class has the getErrorCode()
and getMessage()
methods, which return the Oracle error code and message, respectively.
If a stored procedure called from SQL or PL/SQL throws an exception and is not caught by Java, then the following error message appears:
ORA-29532 Java call terminated by uncaught Java exception
This is how all uncaught exceptions, including non-SQL exceptions, are reported.