Budi, According to JRUN Tech support, the transaction tag is only available if you have the version of JRUN that supports EJB's. If you do, then you need to make sure that you set up the transaction tag per the instructions in the JRUN tag library manual. There are a couple steps you have to take, including recompiling the transaction tag's underlying code, before you can actually use it in your application. Now whether you can use the tag in a servlet, or only in an EJB, is something I am not sure of. You would need to check with JRUN Tech support on that question.
Celeste -----Original Message----- From: Budi Prawira [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 10, 2002 10:05 PM To: JRun-Talk Subject: using transaction from servlets 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 ______________________________________________________________________ Macromedia ColdFusion 5 Training from the Source Step by Step ColdFusion http://www.amazon.com/exec/obidos/ASIN/0201758474/houseoffusion Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
