Forums Register Login

Database Transactions

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 602 times.
Similar Threads
container managed transactions
XADataswource
Transaction attribute Require New in EJB
Transactions
Problem with transaction.timeout
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 01:32:12.