Error handle in Stored Procedure and Java

  • Hi, some one can say why java can't get a sqlexception from SP1 but get the java sqlexception from SP2?

    I'm just a DBA...not a java programmer, but a developer from my company, wants remove all error handling using "begin try...begin catch" from procedures justifying java not throw a exception when call a SP using this kind of error handle

    Create proc SP1

    as

    declare @msg varchar(100)

    set nocount on

    begin try

    select 10/0

    end try

    begin catch

    set @msg = error_message()

    raiserror(@msg, 16,1)

    end catch

    create proc sp2

    as

    set nocount on

    select 10/0

    if @@error<>0

    goto Erro

    return

    Erro:

    raiserror('divide by 0',16,1)

    Any help is welcome 🙂

    thanxs in advance

  • anybody?

  • I'm not a Java programmer, either, so this is speculation on my part.

    If I'm not mistaken, I believe Try-Catch is primarily a Microsoft SQL and .NET function. I'm guessing that Java does not support the Try-Catch structure.

    Again, this is a guess on my part. I'm probably grasping at straws just as much as you are.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply