I feel JTA is the solution. JOTM have a documentation on how to use it in
Tomcat. But requiring to use JNDI is a problem because Tomcat JNDI is not
available outside Tomcat and I cannot run unit tests. Thanks for the help.

rgds
Antony Paul

----- Original Message -----
From: "Shapira, Yoav" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, September 21, 2004 7:00 PM
Subject: RE: [OT] Handling JDBC transactions



Hi,

>    What are the ways to handle transactions in Tomcat ?. No EJB here.
I
>use
>Tomcat standalone. I am using JDBC calls to manage DB. I had used

There are a couple of ways.

One is to roll them yourself: add jta.jar (Java Transaction API,
downloadable from Sun) and your implementation of choice (e.g. Tyrex) to
WEB-INF/lib, and go read a JTA tutorial.  This way is not hard, it's
portable, and as a bonus you would be able to test your transaction code
from unit tests as it won't depend on the servlet container.

The other way is to use Tomcat's JNDI provider.  The J2EE spec requires
Tomcat to provide a UserTransaction (see the JTA docs) factory via JNDI.
Tomcat 4.x used Tyrex for this, see
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
-howto.html#Tyrex%20Connection%20Pool.

Tomcat 5 doesn't use Tyrex as the project seems to be dead:
http://tyrex.sourceforge.net/#News.  So you have to pick another JTA
implementation and follow the guide for using a the JNDI factory
(http://jakarta.apache.org/tomcat/tomcat-5.5-doc/index.html), using the
org.apache.naming.factory.UserTransactionFactory.

Finally, you could simply use an external transaction manager.  This
solution is usually worthwhile only for mission-critical (as in someone
will die if it fails) or very large installation, because these
enterprise-grade transaction managers tend to be very expensive and
complex.  However, recently things like JOTM (ObjectWeb) have really
grown into their own, so you might wish to investigate it.

The downsides to using container- or externally-provided transaction
manager are that you need to learn the configuration syntax, and that
unit-testing is more difficult.

Yoav



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to