Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Transaction problem

Thread view: 
gk - 11 Nov 2006 18:33 GMT
QUESTION 1:

can we use JTA  API in a web container ?

say , i have  a servlet where i am doing transaction to 3 different DB
as a unit.

can we apply transaction here ?

how the transaction will be activated ? does web container has any
transaction manager in built ?

In application server , we use this way ,

UserTransaction tranContext = (UserTransaction)
initContext.lookup("java:comp/UserTransaction"); // this is offered by
app server .
tranContext.begin();
// get and manipulate data sources or EJB's
tranContext.commit();

How do i get  the transactin Context  from an web container ? i want to
run my jsp+servlet in Tomcat

is it possible ?

QUESTION 2:

"..............................................
JTA isn't perfect. In fact, compared to the type of control we'll see
next with container-managed transactions (CMTs) in EJBs, JTA is a blunt
instrument:

If you are using JTA there is no individual control over data sources
and other resources. If you obtain a connection from a data source
within a transaction, that connection will be enlisted within the
transaction. You can't make it not enlisted or force it to commit
otherwise.

You can't suspend a JTA transaction; once the transaction is started it
must be either committed or rolled back. If you try to start another
JTA transaction on the same thread as an existing one, it will cause an
error.
.........................
........................."

does  JTA  has become  obsolete  ?
Arne Vajhøj - 11 Nov 2006 19:51 GMT
> can we use JTA  API in a web container ?
>
[quoted text clipped - 19 lines]
>
> is it possible ?

You can do the same in a servlet container, if you have
a transaction manager.

For Tomcat see:

http://www.onjava.com/pub/a/onjava/2003/07/30/jotm_transactions.html?page=1
http://static.raibledesigns.com/downloads/howto-tomcat-jotm.html

> JTA isn't perfect. In fact, compared to the type of control we'll see
> next with container-managed transactions (CMTs) in EJBs, JTA is a blunt
[quoted text clipped - 10 lines]
> JTA transaction on the same thread as an existing one, it will cause an
> error.

I belive it is implementation specific whether JTA support nested
transactions or not.

> does  JTA  has become  obsolete  ?

No.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.