wood burning stoves 2.0
The moose likes EJB and other Java EE Technologies and the fly likes Container Managed Transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Container Managed Transactions" Watch "Container Managed Transactions" New topic

Container Managed Transactions

Ravi Singh
Ranch Hand

Joined: Aug 02, 2004
Posts: 51
If a stateless bean method, which is part of a larger transaction, updates a database table directly using a standard JDBC connection and SQL statements are the changes made written to a 'cache' and only applied when the entire transaction succeeds and is committed to the database?

For example,

Public void makeChange {

Connection con = // Get Connection

Statement stmt = con.createStatement();

stmt.executeQuery(�INSERT INTO TABLE VALUES 50�);


Are these changes only made to the database when the entire transaction (which this method is a part of) succeeds?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Pretty much. The mechanics of exactly how this happens is down to vendor specific implementations, but you've got the gist of it.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
parthiban subramaniam
Ranch Hand

Joined: May 15, 2002
Posts: 116
That�s the way we go about doing things here at my place.
just 1 wrapper to wrap all the transaction be it just one of or a multiple Data manipulation in the db,
it should work fine.
as long as your session bean does not start a new one but supports the existing trans,

Check to make sure please,

Hope that helps


Even crazy and silly looking problems are sometimes real.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The connection's auto-commit mode is disabled, enabling all the DB updates to be committed or rolled back at the end of a transaction.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
I agree. Here's the link: http://aspose.com/file-tools
subject: Container Managed Transactions
It's not a secret anymore!