Home » SQL & PL/SQL » SQL & PL/SQL » RAISE_APPLICATION_ERROR and Java server code
RAISE_APPLICATION_ERROR and Java server code [message #127827] Wed, 13 July 2005 09:55 Go to next message
ghegarty
Messages: 5
Registered: July 2005
Junior Member
Hi,

Lack of experience is causing me some issues at the minute. I have started working on a Java (Server-Side) connecting to Oracle (business logic in PL/SQL) web application. The application has limited error handling and basically some general error messages are reported back to the user when something goes wrong.

One of our main tasks is to implement some form of error handling.

I have two options in mind:

  1. Create parameters which pass out a response code an error message,
  2. Use the RAISE_APPLICATION_ERROR to propogate the error from the PL/SQL back to the calling Java class.


From the research I have carried out it seems that the general consensus is that the RAISE_APPLICATION_ERROR is the preferred approach but I would appreciate or advice or assistance that you may have.

Thanks in advance,
GH
Re: RAISE_APPLICATION_ERROR and Java server code [message #127875 is a reply to message #127827] Wed, 13 July 2005 17:00 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Absolutely option #2.
Re: RAISE_APPLICATION_ERROR and Java server code [message #127924 is a reply to message #127875] Thu, 14 July 2005 03:04 Go to previous messageGo to next message
ghegarty
Messages: 5
Registered: July 2005
Junior Member
Hi Todd,

Thanks for your reply. Can you give me some short reasons of how I can justify this design decision? Whats the benefits other than what I listed.

One last question, when the raise_application_error is thrown back to the Java, can we catch this is an SQLException and control the presentation of the error message back to the client.

Thanks again.
GH
Re: RAISE_APPLICATION_ERROR and Java server code [message #128020 is a reply to message #127924] Thu, 14 July 2005 11:43 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
The use of RAE allows you to leverage the built-in exception handling at both the Oracle and Java layers. Return codes via parameters is reinventing the wheel and ending up with a wheel that really isn't round.

Yes, you would catch the exceptions via SQLException. Note that the ErrorCodes will come back as positive numbers in Java even though they are negative in Oracle.
Re: RAISE_APPLICATION_ERROR and Java server code [message #128025 is a reply to message #128020] Thu, 14 July 2005 12:52 Go to previous message
ghegarty
Messages: 5
Registered: July 2005
Junior Member
Nice one Todd.

Thanks for your help
Previous Topic: SQL*PLUS column format
Next Topic: export external table
Goto Forum:
  


Current Time: Sun Jan 18 04:31:08 CST 2026