hi prateek,

        u need not make any changes in deployment descriptor. That means
transaction is done explicitly but not implicitly by the container.
        Try using following code in ur session bean, it will surely work.

        U need to import following packages

                                        import
javax.transaction.UserTransaction;
               import javax.transaction.SystemException;
               import javax.transaction.HeuristicMixedException;
               import javax.transaction.HeuristicRollbackException;
               import javax.transaction.NotSupportedException;
               import javax.transaction.RollbackException;


                                Context ctx = getInitialContext();
                                tx =
(UserTransaction)ctx.lookup("java:comp/UserTransaction");
                                tx.begin();
                                if(!gotException)
                                {
                                                try
                                                {
                                                        tx.rollback();

//System.out.println("%%%%%%%rolled backwwwwwwwwwwwwwwwwwwwwwww");
                                                }
                                                        catch(Exception e)
                                                {
                                                }
                                }
                                else
                                {
                                        tx.commit();

//System.out.println("%%%%%%%committed");
                                        //return true;
                                }
                                        //throw new Exception();

        With regards
        Purushotham Das




> -----Original Message-----
> From: Prateek [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 04, 2000 6:59 PM
> To:   [EMAIL PROTECTED]
> Subject:      Transaction rollback
>
> Hello Friends,
>      I tried a very simple program of a client talking to a session bean.
> The session bean consists of a inner java class whose transactions are to
> be
> rolled back... The entity bean firstly successfully creates the inner
> class
> and writes the data to d/b. Now there is an updation happening to the
> inner
> table from the session bean which is written to the database but the
> transaction is not commited. But before the business method of session
> bean
> returns an exception is thrown from the session bean. Now ideally the
> transaction should be rolled back. But its not happening. I have tried
> using
> both the transactions from Session bean manually and also the container
> prvided transactions. But to no avail. Can someone pl. tell me how to
> cause
> a transaction to be rolled back. I am sending my ejb-jar.xml with this
> mail...This is a simple problem of trying to rollback ..Anyhelp would be
> highly appreciated..
> I am sending both my session code and ejb-jar.xml file below..
>
> Session Code:
>
>   conn = ds.getConnection();
>
>    pstmt = conn.prepareStatement(sql);
>    int numrows = pstmt.executeUpdate();
>
>    throw new Exception();
>
>
>
> ejb-jar.xml file code :
>
> <ejb-jar>
>     <enterprise-beans>
>       <session>
>         <ejb-name>SessionCl</ejb-name>
>  <home>pms.session.sess_cl.SessClHome</home>
>  <remote>pms.session.sess_cl.SessClRem</remote>
>  <ejb-class>pms.session.sess_cl.SessClBean</ejb-class>
>  <session-type>Stateless</session-type>
>  <transaction-type>Container</transaction-type>
>        </session>
>     </enterprise-beans>
>     <assembly-descriptor>
>       <container-transaction>
>  <method>
>    <ejb-name>SessionCl</ejb-name>
>    <method-intf>Remote</method-intf>
>    <method-name>*</method-name>
>  </method>
>  <trans-attribute>RequiresNew</trans-attribute>
>       </container-transaction>
>      </assembly-descriptor>
>   </ejb-jar>
> Regards,
> Prateek.
>
> ==========================================================================
> =
> 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