On all platforms running with a JDK of 1.4 or higher, can
successfully prevent a second instance of from
booting the database and thus prevents corruption.
On some platforms running with a JDK lower than 1.4, may
prevent a second instance of from
booting the database (previous to JDK 1.4 the ability to do this was OS dependent).
If this is the case, you will see an SQLException like the following:
ERROR XJ040: Failed to start database 'sample', see the next exception for details.
ERROR XSDB6: Another instance of might have already booted
the databaseC:\databases\sample.
The error is also written to the error log.
If you are running a JVM prior to 1.4, issues
a warning message on some platforms if an instance of attempts
to boot a database that already has a running instance of attached
to it. However, it does not prevent the second instance from booting, and
thus potentially corrupting, the database. (You can change this behavior with
the property derby.database.forceDatabaseLock.)
If a warning message has been issued, corruption might already have occurred.
Corruption can occur even if one of the two booting systems has "readonly"
access to the database.
The warning message looks like this:
WARNING:
(instance 80000000-00d2-3265-de92-000a0a0a0200) is
attempting to boot the database /export/home/sky/wombat
even though
(instance 80000000-00d2-3265-8abf-000a0a0a0200) might still be active.
Only one instance of
should boot a database at a time. Severe and non-recoverable corruption can
result and might have already occurred.
The warning is also written to the error log.
If you see this warning, you should close the connection and exit the
JVM, minimizing the risk of a corruption. Close all instances of ,
then restart one instance of and
shut down the database properly so that the db.lck file can be removed.
The warning message continues to appear until a proper shutdown of the system can delete the db.lck file.
When developing applications, you might want to configure to
append to the log. Doing so will help you detect when you have inadvertently
started more than one instance of in
the same system. For example, when the derby.infolog.append property
is set to true for a system, booting two instances of in
the same system produces the following in the log:
Sat Aug 14 09:42:51 PDT 2005:
Booting version - 10.0.0.1 - (29612):
instance 80000000-00d2-1c87-7586-000a0a0b1300 on database at
directory C:\tutorial_system\sample
------------------------------------------------------------
Sat Aug 14 09:42:59 PDT 2005:
Booting version - 10.0.0.1 - (29612):
instance 80000000-00d2-1c87-9143-000a0a0b1300 on database at
directory C:\tutorial_system\HelloWorldDB
allows you to
boot databases that are not in the system directory. While this might seem
more convenient, check that you do not boot the same database with two JVMs.
If you need to access a single database from more than one JVM, you will need
to put a server solution in place. You can allow multiple JVMs that need to
access that database to connect to the server. The Network
Server is provided as a server solution. See the for
more information on the Network Server.