I have a basic question with user transaction.
I am using EJB (Stateless bean) in one method i am calling UserTransaction.begin() and after some JDBC calls i am commiting the transaction ut.commit(); in the next line i am passing the UserTransaction object to another Java Class there i need to execute a batch in a loop. So every iteration of the loop i am calling the transaction.begin() and i am creating connection and execute three JDBC calls by getting three connection. At the end of the loop i am calling transation.commit().
Connection con = dataSource.getConnection();
Connection con1 = dataSource.getConnection();
Connection con2 = dataSource.getConnection();
While monitoring the pool status in the jmx-console in jboss for each iteration there is only one connection is taken from the pool and after the execution of the finally statement no connection is returned to the pool till the end of the loop.
My understanding with the UerTansaction is transaction is live between the begin and commit method of the user transaction, but it behaves like the transaction is live for the whole loop.
Please advice me what i am doing wrong.
The connection is released only after the loop ends... if the batch contains 1000 then the application fails..