1

I have a query regarding PLSQL exceptions and how to handle them in Java .I have some Stored procedures which upon some exception uses "dbms_output.put_line" to print the error messages. As I can't get these messages in my java "front-end", How should I modify my Stored procedures to get these exceptions?

I can think about two ways but I don't know if these are correct and if they are used in projects.

  • Use an OUT parameter to send this error message to Java, if the SP executes successfully then it will be "null", but in-case some exceptions occurs I will populate this with an error message from my PLSQL EXCEPTION block.

  • RAISE the exception form PLSQL Exception block so I can get the exception using try-catch block of Java as SQLException

Maybe there is some better way which I do not know about.. Kindly suggest me how should I proceed in such situations.


TLDR : How to code PLSQL Exception block so I can handle it in Java. The actual way used in real projects by professionals.

1 Answer 1

2

RAISE the exception form PLSQL Exception block so I can get the exception using try-catch block of Java as SQLException

Better way ... Follow this way .

Sign up to request clarification or add additional context in comments.

2 Comments

If using spring you can map the plsql exceptions to java exceptions.
@FinalFive I am not using spring, but its good to know that spring has such option. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.