[Logo]
Forums Register Login
Database Transactions
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?
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
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 24, 2017 22:41:13.