• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Use of UserTransaction

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a 3 doubts. I implements the client (servlet) that get the userTransaction of Context using this code:

UserTransaction userTrx = (UserTransaction)jndiCtx.lookup("jta/usertransaction");
String temp = null;

userTrx.begin();
temp = "value";
userTrx.roolback();
System.out.println(temp);

My doubt is: The value of temp will "value" or null ?

What is the advantage of use transaction without EJB ?

I can controll in the rollback of the object UserTransaction (get with lookup of context) the command rollback of transaction of DB together without use EJB ?

Thanks
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a JTA transaction only affects resources that can be "enlisted" in the transaction: JDBC connections, JMS queues, etc. While you could certainly write code that would wrap a String and make it transactional, that's not a part of standard Java.
 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserTransaction interface gives control to you,to manage your transaction in your program and container won't take care of Transaction Management.

Regards,

James
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic