5 Replies Latest reply on Sep 17, 2002 2:37 AM by David Jencks

    JCA, UserTransaction and Oracle

    Alexandre Nichet Newbie

      Hi,

      I have a client application which uses transaction demarcation and performs IIOP Stateful SessionBean operations to a Oracle database.
      When I execute my client test application and read the changes, apparently everything seems to be fine. But If I log to theDB I can not see the changes, it seems the change are not committed. If I shutdown JBoss server then the changes are committed, I can see them in the DB.
      I have 2 test codes below: one testXaiiop() test code which uses UserTransaction from client application and testWithXaiiopInterface() which uses UserTransaction in the Session Bean. With these 2 test codes I have the same results.

      Do you have a idea of the problem?

      Thanks.

      My set up:
      JBoss version: 3.0.1
      As database I use Oracle 8.1.7 and latest oracle driver. Also I copied jboss-3.0.1\docs\examples\jca\oracle-xa-service.xml to jboss-service.xml.
      JBoss start command: run -c all

      public static void testXaiiop()
      {
      try
      {
      int status;
      String query = "SELECT * FROM account";
      InitialContext initialContext = new InitialContext();
      XaHome home = (XaHome)PortableRemoteObject.narrow(
      initialContext.lookup(XaHome.JNDI_NAME),
      XaHome.class);
      Xa xa = home.create();

      xa.getConnection(null);
      xa.performQuery(query);
      UserTransaction ut = (UserTransaction) initialContext.lookup("UserTransaction");
      ut.begin();
      // change to the DB
      xa.performUpdate("UPDATE account SET balance = balance + 1");
      ut.commit();

      xa.performQuery(query);

      xa.closeConnection(null);

      xa.remove();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }


      public static void testWithXaiiopInterface()
      {
      try
      {
      int status;
      String query = "SELECT * FROM account";
      InitialContext initialContext = new InitialContext();
      XaHome home = (XaHome)PortableRemoteObject.narrow(
      initialContext.lookup(XaHome.JNDI_NAME),
      XaHome.class);
      Xa xa = home.create();

      xa.getConnection(null);
      xa.performQuery(query);
      xa.beginTransaction(null);
      // change to the DB
      xa.performUpdate("UPDATE account SET balance = balance + 1");
      xa.commitTransaction(null);
      xa.performQuery(query);

      xa.closeConnection(null);

      xa.remove();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }