• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 8945
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: 3892
5
  • 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: 8945
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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic