Connecting to databases outside the system directory

You can also connect to databases in other directories (including subdirectories of the system directory) by specifying a relative or absolute path name to identify the database. The way you specify an absolute path is defined by the host operating system (see java.io.File.isAbsolute). You must specify a path for a database in a directory other than the system directory even if you have defined the derby.service property to have Derby boot the database automatically (see "derby.service" in Tuning Derby).

Using the connection URL as described here, you can connect to databases in more than one directory at a time.

Two examples:

jdbc:derby:../otherDirectory/myDB

jdbc:derby:c:/otherDirectory/myDB
Note: Once connected to, such a database becomes a part of the Derby system, even though it is not in the system directory. This means that it takes on the system-wide properties of the system and that no other instance of Derby should access that database, among other things. It is recommended that you connect to databases only in the system directory. See Recommended practices for suggestions about working with a Derby system.
Related concepts
Connecting to databases within the system