Attaching a patch,
DERBY-5158a, which corrects the protocol code on the client side to cater for ENDUOWRM even in the error case (as sent by the server). Looking at the DRDA standard, I didn't quite manage to satisfy myself that this is the correct behavior, but almost: section 7.5 Commit/Rollback processing, where CR2 says:
"Application servers using remote unit of work protocols and application servers using distributed unit of work but not protected by a sync point manager must inform the application requester when the current unit of work at the application server ends as a result of a commit or rollback request by an application or application requester request. This information is returned in the RPYDSS, containing the ENDUOWRM reply message."
So, does the above apply when an error happens (the database has already been shut down, so no connection can be established)? In a way, the "remote unit of work" is definitely ended, so...
Note that the (new) error stack trace is still different than with the embedded driver, since there the 08003 will be directly reported as the error (not wrapped in 06006 as shown below for the client side).
I added a new test, Derby5158Test, not being sure where to put this new test case (I didn't find any specific tests for commit/rollback), if you know a better placement for it, let me know! I could always put it in ShutdownDatabaseTest, I guess..
With this new code, the following error stack dump can be seen on the client side, which shows that the underlyinc cause of the error is 08003. "No current connection".
java.sql.SQLNonTransientConnectionException: A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message (additional information may be available in the derby.log file on the server)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: org.apache.derby.client.am.DisconnectException: A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message (additional information may be available in the derby.log file on the server)
... 28 more
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08003, SQLERRMC: No current connection.
... 37 more