Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to catch Oracle error codes and error message

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to run oracle procedure/Function using Hibernate 3. I want to catch error raised by oracle procedure/Function and display error message to user.

By using this code I can able to run only procedures and If any error occured in procedure my control is going to SQLException block. I want to check the error message.
Please check this code and let me know is this correct way to call procedure??
Please share document related to calling procedure from hibernate.

Thanks.
 
hildich kilal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the right way you call stored proc from hibernate.
Are you not getting error code in SQLException object? What exactly is your requirement?

Thanks
HK
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kilal,
I'm getting error code in SQLException block, but i want to get error codes in execute statement only.
and what about if function will return some object??
 
hildich kilal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can handle exception in Stored procedure (in EXCEPTION block) assign the error code and error message to two variables. Set these variables as OUT parameters in your stored procedure.

Read them after execute. This way SQLException will not be thrown.

Hope this helps.
HK
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic