# Conventions for specifying the database path

When accessing databases from the file system (instead of from classpath or a jar file), any path that is not absolute is interpreted as relative to the system directory.

The path must do one of the following:

- refer to a previously created Derby database
- specify the create=true attribute

The path separator in the connection URL is / (forward slash), as in the standard file:// URL protocol.

You can specify only databases that are local to the machine on which the JVM is running. NFS file systems on UNIX and remote shared files on Windows (//machine/directory) are not guaranteed to work. Using derby.system.home and forward slashes is recommended practice for platform independent applications.

If two different database name values, relative or absolute, refer to the same actual directory, they are considered equivalent. This means that connections to a database through its absolute path and its relative path are connections to the same database. Within Derby, the name of the database is defined by the canonical path of its directory from java.io.File.getCanonicalPath.

Derby automatically creates any intermediate directory that does not already exist when creating a new database. If it cannot create the intermediate directory, the database creation fails.

If the path to the database is ambiguous, i.e., potentially the same as that to a database that is available on the classpath (see "Special Database Access"), use the directory: subsubprotocol to specify the one in the file system. For example:

    jdbc:derby:directory:myDB

Parent topic: Connecting to databases
Related concepts
Connecting to databases within the system
Connecting to databases outside the system directory
Special database access
Related reference
Database connection examples