• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Database Transactions  RSS feed

 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had assumed that J2EE specified the concept of a database transaction like COM+ does but I cannot find an example.
Can someone point me to an example of a database transaction with rollback in J2EE?
 
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J2EE treats transactions at a slightly higher level than the database. In essence, there are various ways in which the transactionality of EJB components can be defined - both programmatically and declaratively.
When interacting with the database through JDBC, instead of using a "database transaction" you would use a JTA (Java Transaction API) transaction. If you have defined your beans to use container managed transactions (CMT), then this is done for you behind the scenes. If you are using bean managed transactions (BMT, on session beans only) then you have to "look up" a transaction object (of type UserTransaction) and explicitly start and commit (or rollback) it.
From within this context, by looking up and using a transactional DataSource, the transactional context can be carried forward. Therefore, if you rollback the JTA transaction, the underlying database transaction will also get rolled back.
I really hope that makes sense!
As for examples, take a look at the J2EE Tutorial on the java.sun.com site, or even the documentation that ships with BEA WebLogic (at www.weblogic.com) as this also has some "tutorial" style documentation.
Hope that helps...
Simon
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!