# Derby system

A Derby database exists within a system.

A Derby system is a single instance of the Derby database engine and the environment in which it runs. It consists of a system directory, zero or more databases, and a system-wide configuration. The system directory contains any persistent system-wide configuration parameters, or properties, specific to that system in a properties file called derby.properties. This file is not automatically created; you must create it yourself.

The Derby system is not persistent; you must specify the location of the system directory at every startup.

However, the system - as well as its directory, which you name - is an essential part of a running database or databases. Understanding the Derby system is essential to successful development and deployment of Derby applications.

Figure 1. Derby databases live in a system, which includes system-wide properties, an error log, and one or more databases.

The system directory can also contain an error log file called derby.log (see The error log).

Each database within that system is contained in a subdirectory, which has the same name as the database (see A Derby database).

In addition, if you connect to a database outside the current system, it automatically becomes part of the current system.

- One Derby instance for each Java Virtual Machine
  You could potentially have two instances of a Derby system (JVM) running on the same machine at the same time. Each instance must run in a different JVM. Two separate instances of Derby must not access the same database.
- Booting databases
  The default configuration for Derby is to boot (or start) a database when an application first makes a connection to it. When Derby boots a database, it checks to see if recovery needs to be run on the database, so in some unusual cases booting can take some time.
- Shutting down the system
  In an embedded environment, when an application shuts down, it should first shut down Derby.
- Defining the system directory
  You define the system directory when Derby starts up by specifying a Java system property called derby.system.home.
- The error log
  Once you create or connect to a database within a system, Derby begins outputting information and error messages to the error log.
- derby.properties
  The text file derby.properties contains the definition of properties, or configuration parameters that are valid for the entire system.
- Double-booting system behavior
  Derby attempts to prevent two instances of Derby from booting the same database by using a file called db.lck inside the database directory.
- Recommended practices
  When developing Derby applications, create a single directory to hold your database or databases.

Parent topic: Derby embedded basics
Related concepts
Derby JDBC driver
Derby JDBC database connection URL
A Derby database
Connecting to databases
Working with the database connection URL attributes
Connections