0 Replies Latest reply on Jan 30, 2002 11:19 AM by kuding2000

    Should I worry about it?

    kuding2000

      In one of EJB, I connect to database in ejbCreate() like this,

      InitialContext ic = new InitialContext();
      DataSource ds = (DataSource) ic.lookup(dbName);
      if(ds == null)
      cat.fatal("DataSource is null!!!");
      con = ds.getConnection();
      ....

      and this ejb has two method to be called to do database commit and rollback()
      public void commit() throws RemoteException
      {
      try{
      con.commit();
      }catch(Exception ex){
      cat.error(ex.getMessage());
      throw new RemoteException(ex.getMessage());
      }
      }
      public void rollback() throws RemoteException
      {
      try{
      con.rollback();
      }catch(Exception ex){
      cat.error(ex.getMessage());
      throw new RemoteException(ex.getMessage());
      }
      }



      A client application will do some database operation in a transaction on the connection created in EJB, at the end of transaction, client call commit() method of EJB if everything is ok, or else, call rollback().

      my question is, if one instance (instance 1)of the client app is running, and then at this time, another instance (instance 2)finish and call the commit() method in EJB before it ends, it seems that the partly work have been done in instance1 should also be committed to database server.

      I have not done a real test about it, but, should I worry about it?