Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
10.9.1.0
-
None
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.