• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

about JTA

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everybody:
can someone tell me that how to use JTA without using EJB in J2EE
Environment?
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javax.transaction.UserTransaction userTransaction = null;
try{
userTransaction = context.getUserTransaction();
userTransaction.begin();
.......................
//operations inside the transaction
.......................
userTransaction.commit();
}catch(Exception e){
if(userTransaction != null) userTransaction.rollback();
....
}
Something like this.
 
kenshin Lin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sergiu truta:
thanks for yuor reply, but i want to know is "how to use JTA interface",
without "EJBContext" object in J2EE Environment.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"kenshin",
We don't have many rules here at the ranch but your display name is currently violating one of the few. You can change your display name here.
Thanks. And welcome to the JavaRanch!
 
Ranch Hand
Posts: 8953
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kenshin:
hi sergiu truta:
thanks for yuor reply, but i want to know is "how to use JTA interface",
without "EJBContext" object in J2EE Environment.


Do a JNDI lookup .
 
author
Posts: 3902
10
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you probably meant "Do a JNDI lookup of the UserTransaction".
Kyle
 
Pradeep bhatt
Ranch Hand
Posts: 8953
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kyle Brown:
I think you probably meant "Do a JNDI lookup of the UserTransaction".
Kyle


Yes.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Context jndiCntx = new InitialContext();
UserTransaction tran =
(UserTransaction)jndiCntx.lookup("java:comp/UserTransaction");
utx.begin();
...
utx.commit();
I think you need to use the JNDI and JTA API, and most of the application servers bundle these relevant classes...
 
Happily living in the valley of the dried frogs with a few tiny ads.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic