1 Reply Latest reply on Oct 30, 2001 7:40 PM by Erik Sliman

    ejbRemove rolling back

    Erik Sliman Apprentice

      I finally got everything appearing to work, except the ejbRemove(). Updates and Creates seem to work.

      Here is the source code:

      public void ejbRemove() {
      try {
      deleteOrganization(acronym);
      System.out.println("ejbRemove() successfully ran for " + acronym);
      } catch (Exception ex) {
      System.out.println("ejbRemove() exception for " + acronym + " is " + ex.getMessage());
      throw new EJBException("ejbRemove: " + ex.getMessage());
      }
      }

      private void deleteOrganization(String acronym) throws SQLException {

      System.out.println("entering deleteOrganization() for " + acronym);

      try {
      Connection con = getConnection();

      try {
      String deleteStatement =
      "delete from " + tableName +
      " where acronym = ?";
      PreparedStatement prepStmt =
      con.prepareStatement(deleteStatement);

      try {
      prepStmt.setString(1, acronym);
      System.out.println("executing SQL in deleteOrganization() for " + acronym);
      prepStmt.executeUpdate();
      System.out.println("sucessfully executed SQL in deleteOrganization() for " + acronym);
      } finally {
      prepStmt.close();
      System.out.println("deleteOrganization(), prepStmt closed for " + acronym);
      }
      } finally {
      con.close();
      System.out.println("deleteOrganization(), con closed for " + acronym);
      }
      } catch (NamingException ex) {
      System.out.println("deleteOrganization(), naming exception for " + acronym);
      throw new EJBException("deleteOrganization naming exception: " + ex.getMessage());
      }
      System.out.println("exiting deleteOrganization() for " + acronym);
      }

      Here is the output:

      [Default] entering deleteOrganization() for MORE
      [MySQLDB] No transaction right now.
      [MySQLDB] Pool MySQLDB [1/1/202] gave out pooled object: org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@35998f
      [Default] executing SQL in deleteOrganization() for MORE
      [Default] sucessfully executed SQL in deleteOrganization() for MORE
      [Default] deleteOrganization(), prepStmt closed for MORE
      [MySQLDB] Pool MySQLDB [0/1/202] returned object org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@35998f to the pool.
      [Default] deleteOrganization(), con closed for MORE
      [Default] exiting deleteOrganization() for MORE
      [Default] ejbRemove() successfully ran for MORE

      Yet, here is the MySQL log:

      10 Query SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
      10 Query delete from Organizations where acronym = 'MORE'
      10 Query rollback

      Just noticed selects are rolling back too:

      10 Query SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
      10 Query select acronym, name, orgtype, httpurl from Organizations where acronym = 'MORE'
      10 Query rollback

      Please help.

      Erik

        • 1. Re: ejbRemove rolling back
          Erik Sliman Apprentice

          Solved problem. Needed a Required transaction on remote interface. Another left over from Sun examples.

          Does anyone know if JBoss 3.0 will be able to better run Sun examples. Not that I using them again. But, it would surely help the learning curve of others, as well as increase conformity.