Re: SQLServerException and Raiserror





Shantanu wrote:

I do not have access to connection or statement.

Ok, then you're out of luck unless you have access to the
JDBC objects involved...
Joe

I just get SQLServerException thrown to me. I tried doing getCause() and getNextException() but no luck.

Thanks
Shantanu

"Joe Weinstein" wrote:



Shantanu wrote:


Hello,

I am bit new to SQLServer JDBC drivers. We have a database trigger that raises a user defined exception using Raiserror. e.g. Raiserror( 'Trigger has failed because ......

When I get SQLServerException in my Java code, I can only access the server error that says something like below

SQL Error: 3609, SQLState: S0001
The transaction ended in the trigger. The batch has been aborted.

Is there a way I can access error message defined by me?

Many Thanks

Make the getWarnings() call on the connection and statement, and see if
the raiserror message is attached via warnings. Also call the SQLException's
getNextException() to see if you got a chain of exceptions, with the info
you want in one of those.
Joe Weinstein at BEA Systems



.


Loading