A script-enabled browser is required for this page to function properly.

ORA_JAVA.LAST_EXCEPTION

This function returns the last Java exception that occurred when calling Java from PL/SQL. Use when the PL/SQL exception raised is ORA_JAVA.EXCEPTION_THROWN.

Note that if you do not add explicit exception handlers to your code, then these Oracle errors might be thrown instead of a named exception:

Syntax

FUNCTION ORA_JAVA.LAST_EXCEPTION RETURN ORA_JAVA.JEXCEPTION;

Returns

An object of type ORA_JAVA.JEXCEPTION, which is a subtype of ORA_JAVA.JOBJECT.

Usage notes

Whenever you issue a call to a Java method in a PL/SQL block, it is good practice to use this Built-in in the exception-handling part of the calling block to handle the ORA_JAVA.EXCEPTION_THROWN type of PL/SQL exception that can occur, e.g., NULL pointer. Note that when ORA_JAVA.EXCEPTION_THROWN is thrown, this indicates that an exception was thrown from within the Java method that was being called.

Example

/*
** This example assumes you have imported the
** java.lang.Exception class.
*/

PROCEDURE foo IS
 obj ORA_JAVA.JOBJECT;
 excp ORA_JAVA.JEXCEPTION;
BEGIN
 obj := jfoo.new;
 jfoo.addElement(obj);
 EXCEPTION
 WHEN ORA_JAVA.EXCEPTION_THROWN THEN
  excp := ORA_JAVA.LAST_EXCEPTION;
  OFM_MESSAGE(' Java Exception: ' ||
  exception_.toString(excp));
  ...
END;

See also

Handling Java Exceptions from PL/SQL Code

ORA_JAVA.LAST_ERROR

ORA_JAVA.CLEAR_EXCEPTION