Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5910

Document use of Connection.close() with try-with-resources

    XMLWordPrintableJSON

Details

    Description

      The Java SE 7 try-with-resources feature can cause problems with AutoCloseable objects like java.sql.Connection. You must be careful when writing portable code which declares Connections in the initializers of try-with-resources blocks, because Derby raises an exception if you try to close a Connection with uncommitted work in-flight.

      Changing Derby's Connection.close() to always commit in-flight work (and not raise an exception) would create backward compatibility issues, but we do not know yet how serious these issues would be, owing to a lack of data.

      Rather than change Derby's behavior now, we should document how Derby's Connection.close() behaves and describe the portability issues involved in declaring Derby Connections in try-with-resources initializers.

      Attachments

        1. DERBY-5910.diff
          5 kB
          Camilla Haase
        2. DERBY-5910.stat
          0.1 kB
          Camilla Haase
        3. DERBY-5910.zip
          6 kB
          Camilla Haase
        4. DERBY-5910-2.diff
          6 kB
          Camilla Haase
        5. DERBY-5910-2.zip
          6 kB
          Camilla Haase
        6. DERBY-5910-3.diff
          6 kB
          Camilla Haase
        7. DERBY-5910-3.zip
          6 kB
          Camilla Haase
        8. DERBY-5910-4.diff
          7 kB
          Camilla Haase
        9. DERBY-5910-4.zip
          6 kB
          Camilla Haase

        Activity

          People

            chaase3 Camilla Haase
            chaase3 Camilla Haase
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: