• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

how to define a transaction in servlets?

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as per jdbc 3 spec one jdbc connection forms one transaction. i.e. when we fetch a database connection via DataSource connection pooling of a application server like weblogic, all the sql statements will be commited when we close the connection. i hope i am right.

now if a methodA in a servlet makes multiple subsequent method calls, wherein each method call fetches its own database connection and performs sql statements; and it is required that either all methods called in methodA be successful together or none,i.e. methodA forms a single transaction, what should i do?use JTA UserTransaction?
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way:

Use the same Connection object. Call connection.getAutoCommit(false). Call connection.commit() when your transaction(as defined by you) is complete.
[ August 04, 2004: Message edited by: Rovas Kram ]
 
kriti sharma
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone tell me how to use JTA to create a transaction?is it just by using UserTransaction interface?
reply
    Bookmark Topic Watch Topic
  • New Topic