Calling Thread.interrupt will cause derby to shutdown in some cases. To quote the Derby Guide: "As a rule, do not use Thread.interrupt() calls to signal possibly waiting threads that are also accessing a database, because Derby may catch the interrupt and close the connection to the database. Use wait and notify calls instead."
This is actually bad because some libraries will call Thread.interrupt and so on. And in some cases it's good practice depending on what you're doing. In my opinion this is a big design flaw of the database engine.
In any case the only solution I found was that if you're going to call Thread.interrupt(), then you need to adjust the Derby source code to ignore these thread interruptions. Specifically the method noteAndClearInterrupt(...)
in the class org.apache.derby.iapi.util.InterruptStatus