Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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. DBCP-264-clearBatch.patch
        1 kB
        Niall Pemberton
      2. clearBatchPatch.txt
        0.6 kB
        Phil Steitz

        Activity

        Hide
        Hauke Rabe added a comment -

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

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

        Looks like this should be looked at for 1.3.

        Show
        Henri Yandell added a comment - Looks like this should be looked at for 1.3.
        Hide
        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
        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
        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
        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
        Phil Steitz added a comment -

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

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

        OK I committed that patch with the volatile change:

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

        Show
        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:
            Hauke Rabe
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development