UserTransaction and Database Connection


General J2EE: UserTransaction and Database Connection

  1. UserTransaction and Database Connection (2 messages)

    Hi all,
     I was doing some JDBC work inside an UserTransation and observed the following.
    1)It doesn't matter whether you had opened DB connection after or before calling begin() method of UserTransation. The only thing required is that statement.execute() should be called after the begin() method call.

    2) Also, it doesn't matter whether you are closing DB connection after/before calling UserTransation.commit().

    Can somebody validate my observation and provide me explanation of data being committed by TransactionManager even after the connection.close() is called (ie my second observation)?

    Thanks & Regards
  2. After Commit, connection release[ Go to top ]

    By practise, the db connections marked under transaction must be released before commit.This makes the connection object to participate in pooling.
    A connection under a transaction is not shared !
  3. Manish:

    It makes perfect logical sense for what you observed to be true. Because by default most TMs enlist open connections in the current thread as txns start on "that thread" (THread ID based).