Thanks for the reply!

David, I have set the autocommit attribute of Connection class to false. It
still does not work. The funny thing is, when I deploy the application to
Orion 1.5.2 server, it works!

About the transaction tag, from Celeste, I'm not sure if I understand your
explanation. I don't use any JSP at all.

I should be able to use transaction from servlets. I know this for sure, but
I just don't know how to do it in JRun...

regards,
Budi

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 11 January 2002 23:58
> To: JRun-Talk
> Subject: using transaction from servlets
> 
> 
> Hi Budi,
> I emailed you recently with a suggestion.  Here's a copy in 
> case of delivery
> failure:
> 
> Have you set AutoCommit to false.  By default it is set to 
> True in JRun.
>  e.g   tConnection.setAutoCommit(false);
> 
> Also:  I think it would be a good idea to put the 
> tx.rollback() statement
> within a try catch block.
> 
> 
> Regards
> David O'Mahony
> Syntegra
> mailto:[EMAIL PROTECTED]
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: 11 January 2002 10:20
> To: [EMAIL PROTECTED]
> Subject: JRun-Talk-List V1 #40
> 
> 
> JRun-Talk-List                 Fri, 11 Jan 2002           
> Volume 1 : Number
> 40
> 
> In this issue:
> 
>         using transaction from servlets
> 
> 
> ----------------------------------------------------------------------
> 
> Date: Fri, 11 Jan 2002 11:05:28 +0700
> From: Budi Prawira <[EMAIL PROTECTED]>
> Subject: using transaction from servlets
> Message-ID: 
> <[EMAIL PROTECTED]>
> 
> Has anybody ever tried to use JRun transaction service from servlets,
> without any EJB?
> I tried but it does not work.
> 
> I attached a sample source code, and the database script. I 
> used JRun 3.1
> with Oracle and MySQL. Both do not work, meaning that the 
> data is committed.
> 
> The sample source code is about creating an order with three 
> order lines.
> The business process is implemented in the servlet 
> (CreateOrderServlet), and
> accessing the database is done in the data-access objects 
> (OrderDAO and
> OrderLineDAO). The transaction is set up in the servlet:
> 
> =============================================
>     try {
>       try {
>         tx.begin();
> 
>         System.out.println("adding new order");
>         orderDAO.addOrder(orderId);
>         System.out.println("new order added: " + orderId);
>         for (int i = 0; i < productId.length; i++) {
>           System.out.println("adding new order line");
>           
> orderLineDAO.addOrderLine(orderId,productId[i],productQty[i]);
>           System.out.println("new order line added: " + productId);
>         }
> 
>         tx.commit();
>       } catch (DAOException daox) {
>         tx.rollback();
>         writeFailResponse(res,daox.getCausedByException());
>         return;
>       }
>     } catch (Exception x) {
>       writeFailResponse(res,x);
>       return;
>     }
> ========================================================
> 
> Now, on the second order line addition, a DAOException is thrown (to
> simulate a database failure). When this happens, the previous 
> transaction
> must be cancelled (i.e.: the order and the first order line 
> must be rolled
> back).
> 
> When I run this servlet, and then I checked the database, the 
> order and the
> first order line are still there, meaning that they are committed.
> 
> Anyone can help?
> Budi
> 
> 
> 
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to