Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-3594

On executing readonly query, WrappedConnection.checkTransactionStatus throws exception when transaction is marked for roll back

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • EAP_EWP 5.1.0
    • EAP 5.0.0, 4.3.0.GA_CP07
    • JCA
    • None
    • JBoss-EAP-4.3_CP7, MySQL 5.0.84, MySQL JDBC Driver Version 5.1.10 , JDK-1.6.0_17

    • Documentation (Ref Guide, User Guide, etc.), Compatibility/Configuration

      Unable to execute read-only query when UserTransaction set to setRollbackOnly() . This does not appear to be a problem associated with transactions but JCA. A change of status from active to rollbackOnly within the same transaction is not in itself sufficient grounds to require the rejection of the second sql statement, since it does not endanger the ACID guarantees. Executing further operations on a tx that is going to rollback is arguably a waste of effort, but won't actually result in data inconsistency even if some of them are updates - they will all be reverted when the tx rolls back.

      Test code :

      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      Connection connection = null;
      try

      { InitialContext initialContext = new InitialContext(); UserTransaction ut = (UserTransaction) initialContext.lookup("java:comp/UserTransaction"); ut.begin(); DataSource ds = (DataSource) initialContext.lookup("java:/DefaultDS"); connection = ds.getConnection(); connection.prepareCall("select * from JBM_USER").execute(); ut.setRollbackOnly(); connection.prepareCall("select * from JBM_USER").execute(); ut.rollback(); }

      catch (SQLException ex)

      { ex.printStackTrace(); } catch (NotSupportedException ex) { ex.printStackTrace(); }

      catch (SystemException ex)

      { ex.printStackTrace(); }

      catch(NamingException e)

      { e.printStackTrace(); }

      finally

      { if(out != null) out.close(); closeConnection(connection); }

      }

        1. error_log.txt
          7 kB
        2. patch.txt
          1 kB
        3. jbpapp-3594.patch
          4 kB

              smarlow1@redhat.com Scott Marlow
              rhn-support-tywickra Tyronne Wickramarathne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: