Derby prevents two instances of itself from booting the same database by using a file called db.lck inside the database directory.
If a second instance of Derby attempts to boot an already running database, the following error messages appear:
ERROR XJ040: Failed to start database 'firstdb', see the next exception for details. ERROR XSDB6: Another instance of Derby may have already booted the database /home/myself/DERBYTUTOR/firstdb.
In addition, a stack trace appears in the derby.log file. For help diagnosing a double boot problem, use the derby.stream.error.logBootTrace property to obtain information about both successful and unsuccessful boot attempts. The property is described in the Derby Reference Manual.
If Derby is not able to create the db.lck file when booting a database, the database will be booted in read-only mode. This may happen due to lack of disk space or access rights for the database directory. The boot message in the derby.log will state that the database has been booted in READ ONLY mode. See also Creating Derby databases for read-only use.
If you need to access a single database from more than one Java Virtual Machine (JVM), you will need to put a server solution in place. You can allow applications from multiple JVMs that need to access that database to connect to the server. The Derby Network Server is provided as a server solution. For basic information on starting and using the Network Server, see Getting Started with Derby. See the Derby Server and Administration Guide for more information on the Network Server.