2 Replies Latest reply on Nov 26, 2004 4:28 AM by Zhaobo

    Associations between Transaction and Connection?

    Zhaobo Newbie

      How jboss associates database connection(java.sql.Connection) with transaction?

      example

       xxmethod {
       ...
       UserTransaction ut = ctx.lookup("UserTransaction");
       ut.begin();
       call xx.method1();
       call xx.method2();
       ut.commit;
       ...
       }
       public class xx {
       public static void method1() {
       ...
       DataSource ds = ctx.lookup("java:/xxDS");
       Connection con = ds.getConnection();
       ...
       con.close();
       }
      
       public static void method1() {
       ...
       DataSource ds = ctx.lookup("java:/xxDS");
       Connection con = ds.getConnection();
       ...
       con.close();
       }
       }
      


      In this example, connection in method1 is different instance from connection in method2. when method1 success, connection is freed to Connection Pool? if it is, where transaction with connetion in method1 go? where is transaction info kept? In TM?

      thanks