Two Laptop Bag*
The moose likes JDBC and the fly likes User Defined SQLException... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "User Defined SQLException..." Watch "User Defined SQLException..." New topic
Author

User Defined SQLException...

Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Hi,

My problem description is to generate a User Defined SQLException.
Here is a look

Let's suppose at any time in Stored Procedure I need to raise a user defined Exception and then in catch block of Stored Procedure we are catching it and handling it, now if we want to propagate the same exception with same message to the JAVA side, how can we do it.

Because whenever we try to raise the same exception to java side from Stored Procedure it is getting automatically packed in SQLException.


Now is there any way out, through which we can make our own exception and can directly catch it from Stored Procedure in JAVA without using SQLException. And how we need to map that exception with Oracle's Stored Procedure.


The Best way to predict your future is to create it - Every great individual common man
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Moving to JDBC forum...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Paul Sturrock:
Moving to JDBC forum...


How can you say that it's fit for JDBC forum,

I am 90% sure that it's related to JAVA technology not with JDBC technology.

Paul could you please throw some light on this.
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Originally posted by Ankur Sharma:


How can you say that it's fit for JDBC forum,

I am 90% sure that it's related to JAVA technology not with JDBC technology.

Paul could you please throw some light on this.


It is obviously a JDBC related question. I guess by reading it for the first time, you might be thinking that it is related to Java Exception handling.

You are 90% sure that it belongs to Java technology but Paul is 100% certain that it is JDBC question. ;)
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Ankur is not not acceptable to catch the SQLException and create your custom exception ? (as the SQLException contains the complete info you need)
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Srikanth Basavaraju:
Ankur is not not acceptable to catch the SQLException and create your custom exception ? (as the SQLException contains the complete info you need)


No Even I also don't want to catch SQLException and wrap it into a custom Exception,

What I want to do is, raise a User Defined Exception and catch it through my user defined Exception Catch block in JAVA prior to catch block of SQLException.

I hope I made it clear.

Let me know if need any clarifications.
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
This feature must be provided at JDBC driver level and I dont think anyone does that.
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Srikanth Basavaraju:
This feature must be provided at JDBC driver level and I dont think anyone does that.



Well I am not sure about it, but the reason why I thought this is because we can map our own Data bean to JAVA Object type with the help of SQLData.java class.

In the same way I though if this is poosible then do let me know.
 
Consider Paul's rocket mass heater.
 
subject: User Defined SQLException...
 
Similar Threads
Partial Flushing of response
Raise an Exception in PL/SQL but not got @ JAVA End
java oracle simultaneous transaction problem
How to capture the exception in oracle trigger from Java client?
User Defined SQLException...