< Prev - Examples - Next >

Raise Application Error

Example Description

Important Notes !

PL/SQL Procedure : RAISE_EXCEPTION
create or replace procedure raise_exception
is
begin
  raise_application_error(-20000, 'just throw an exception displaying this senseless text information');
end raise_exception;
Java Calling Class : RaiseApplicationError.java
package plsql_workbench_examples;

import factory.ExamplesRPCFactory;
import service.RaiseExceptionService;

public class RaiseApplicationError {
  public static void main(String[] args) {
    try {
      // getting the service
      RaiseExceptionService service = ExamplesRPCFactory.getRaiseExceptionService();

      // calling the stored procedure
      service.call();
      
      System.err.println("NO - call has to throw a SQLException");
    }
    catch (Exception e) {
      System.out.println(">>> Message :\n" + e.getMessage());
      System.out.println(">>> Stacktrace :");
      e.printStackTrace(System.out);
    }
  }
}