Bean-Managed Transactions

Using BMT, the transaction is controlled programmatically in the code surrounding the update operations. BMT allows transaction demarcation, the selection of transaction boundaries, to be any arbitrary location in the code, as shown in the following example.

 ... javax.transaction.UserTransaction ut; javax.ejb.EJBContext context; ... try { // // establish the connections and create the // statements // InitialContext init = new InitialContext(); DataSource accountingDS = init.lookup( "java:comp/env/jdbc/accounting"); DataSource legacyAccountingDS = init.lookup( "java:comp/env/jdbc/accountingL"); java.sql.Connection conAcctg = accountingDS.getConnection(); java.sql.Connection conLegacy = accountingDS.getConnection(); ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.