I've a doubt regarding release of connection in transaction handling scenarios in EJB.
Let us assume I have an EJB method associated with a transaction attribute as Requires New (i.e. the ejb method is associated with container managed transaction).
Within that method two diffreent databasess are accessed, connections are created, databases are updated but connections are not realeased.
The code goes similar to the one given below -
public void beanMethod1()
InitialContext cntx = new InitialContext();
javax.sql.DataSource ds1 = cntx.lookup("dataSourceName1");
javax.sql.DataSource ds2 = cntx.lookup("dataSourceName2");
java.sql.Connection conn1 = ds1.getConnection();
PreparedStatement pst1 = ds1.prepareStatement("Qyery1");
java.sql.Connection conn2 = ds2.getConnection();
PreparedStatement pst2 = ds2.prepareStatement("Qyery2");
Now in this context my doubt is - will the transaction manager, along with handling commit/rollback, release the connections also (once commit/rollback is over) ? Or releasing of connections need to be handled in the bean method ?
If releasing connections has to be handled in the bean method, then how does transaction manager execute a commit/rollback on a released connection ?
The same doubt can be extended to bean managed transaction also where transaction boundarry is demarcated using javax.transaction.UserTransaction object's begin(), commit() and rollback() methods.
It will be a real help if anyone please throw some light on this doubt.
Thanks in advance,