Working with database threads in an embedded environment

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.

There are also special considerations when working with more than one database thread in an application, as described in Working with multiple threads sharing a single connection.

When queries, batches, and statements that wait for database locks run longer than expected, you can use interrupts to stop them. If you do, the connection will be closed and an exception will be thrown.

If you design an application whose database threads may see interrupts, you should plan for the following behavior:

Related concepts
The JDBC connection and transaction model
Result set and cursor mechanisms
Locking, concurrency, and isolation
Working with multiple connections to a single database
Working with multiple threads sharing a single connection
Working with Derby SQLExceptions in an application