You can achieve that by using exceptions as they should be used, avoiding "if"
statements, and other ugly workarounds, like below :

public void method1()
{
   try
   {
      // Some SQL code...
      method2 ();
   }
   catch (SQLException sqlCodeException)
   {
      // Handle SQL code error
   }
}

Remember each instruction of the try block will be executed only if the
previous one hasn't thrown any exception. Consequently, this try block is the
"ideal" instruction block (when no error occurs), and error management is
outside this ideal block.

Sameer Tyagi wrote:

> onsider a statless CMT bean with 2 methods, method1() and method2().
>
> method1() invokes method2() like below.
>
> public void method1(){
>   try{
>         >>>>> Some sql code...
>       }catch(SQLExceptoin e){
>         //do something here
>         }
>   method2();
>         }
>
> To preserve integrity,method2 must be executed when the preceeding sql
> code is sucessfully executed.
>
> How can this be done with transactions WITHOUT doing a return in the
> catch block ???
>
> No matter what attributes are set in the dd for both the methods,the
> method2() always seem to
> execute.?
>
> Any ideas ?
> -Sam
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to