Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      If a statement contains batch statements, these statements should be cleared on close.

      Szenario:
      A pooled statement contains already some batch statements before an error occured. This error will be handled and finally the statement will be closed. Cause, it is a pooled statement the batch statements will be remaining in the pooled statement. On the next request the pooled statement will execute the batch statements from the first request.

      1. clearBatchPatch.txt
        0.6 kB
        Phil Steitz
      2. DBCP-264-clearBatch.patch
        1 kB
        Niall Pemberton

        Activity

        Hide
        hbmann Hauke Rabe added a comment -

        Add to org.apache.commons.dbcp.DelegatingStatement#close() method call clearBatch()

        Show
        hbmann Hauke Rabe added a comment - Add to org.apache.commons.dbcp.DelegatingStatement#close() method call clearBatch()
        Hide
        bayard Henri Yandell added a comment -

        Looks like this should be looked at for 1.3.

        Show
        bayard Henri Yandell added a comment - Looks like this should be looked at for 1.3.
        Hide
        psteitz Phil Steitz added a comment -

        The logical place to insert a clearBatch is in PoolablePreparedStatement's passivate method. The attached patch does that, but swallows any SQLException that occurs. Since driver support for this is optional, I don't think we would want to propagate the associated SQLExceptions here; but I don't either like the swallowing and the fact that the try/throw/catch will be executed on every passivate for drivers that do not support batch processing. Anyone have a better idea?

        Show
        psteitz Phil Steitz added a comment - The logical place to insert a clearBatch is in PoolablePreparedStatement's passivate method. The attached patch does that, but swallows any SQLException that occurs. Since driver support for this is optional, I don't think we would want to propagate the associated SQLExceptions here; but I don't either like the swallowing and the fact that the try/throw/catch will be executed on every passivate for drivers that do not support batch processing. Anyone have a better idea?
        Hide
        niallp Niall Pemberton added a comment -

        How about setting a flag when addBatch() is called and only trying to call clearBatch() if that flag is set?

        Show
        niallp Niall Pemberton added a comment - How about setting a flag when addBatch() is called and only trying to call clearBatch() if that flag is set?
        Hide
        psteitz Phil Steitz added a comment -

        Second patch looks good to me. Might want to make the flag volatile, though.

        Show
        psteitz Phil Steitz added a comment - Second patch looks good to me. Might want to make the flag volatile, though.
        Hide
        niallp Niall Pemberton added a comment -

        OK I committed that patch with the volatile change:

        http://svn.apache.org/viewvc?view=rev&revision=738288

        Show
        niallp Niall Pemberton added a comment - OK I committed that patch with the volatile change: http://svn.apache.org/viewvc?view=rev&revision=738288

          People

          • Assignee:
            Unassigned
            Reporter:
            hbmann Hauke Rabe
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development