Connections handling during Transaction


EJB design: Connections handling during Transaction

  1. Connections handling during Transaction (1 messages)


    I have four methods two of them are in one stateless session bean and other two are in another stateless session bean. A method in another stateless session bean calls all these four methods and executing them as a single transaction. The transactional attribute for all the four methods mentioned are "Required". In each method, I take the connection from the connection pool and close them in the finally block. There is no connection.commit().

    But, as far as I know, the transactions should use a single connection. But here, all the methods take the connection from the pool and use them and finally close them. I am getting how the transaction is happening in such situation. How does the application server take care of this situation? Are all the connections held up until the transaction is over?

    Could you please clarify me, whether the approach for transaction I mentioned here is correct or not? If yes, please clarify my doubts.

    Thank you.

  2. It looks for methat you dont using user transaction. To clarify some things, here is my approach to your problem.
    If the method which calls the other four ones can do all the things in a transaction and is in the Remote than put the tx requiered for these method in the bean contract.

    If you would go with user transaction, you have to call the TransactionManager to get a transaction that is know in the container.

    Your problem is that the connection from the pool is a connection to a single source and the container is not aware of it.