Attaching patch 1a, which consists of the following changes:
a) Make Derby close the trace file when the physical connection is closed and the trace file is specified using 'traceFile' (attribute or setter).
b) Disabled the test 'testClientMessageTextConnectionAttribute', as the test started failing when I corrected the test. It was using (ConnectionPool|XA)DataSource.getConnection() to obtain a connection. This method is not an API method, it's an artifact due to Derby's subclassing (the two mentioned data sources extend ClientBaseDataSource).
DERBY-4067 trace the problem that the connection attributes are not picked up.
c) Made the tests obtain the physical connections from data source by using the correct method (i.e. getXAConnection, getPooledConnection or getConnection).
d) Extended the test 'testClientTraceFileDSConnectionAttribute' to also make sure the trace files can be deleted (regression test for
e) Added 'getPhysicalConnection(Object ds)' for the cases where a physical connection is to be obtained, but the data source can be of any (Derby) type.
I need someone to test this patch on Windows, i.e. that jdbcapi.J2EEDataSourceTest.testClientTraceFileDSConnectionAttribute fails without the changes to ClientBaseDataSource.
Patch ready for review.