# Connecting to databases

You connect to a database using a form of the Derby connection URL as an argument to the DriverManager.getConnection call.

For details on the syntax of the connection URL, see "Syntax of database connection URLs for applications with embedded databases" in the Derby Reference Manual.

You specify a path to the database within this connection URL.

- Connecting to databases within the system
  The standard way to access databases in the file system is by specifying the path name of the database. The path name can be either an absolute path name or a path name relative to the system directory. In a client/server environment, this path name is always on the server machine.
- 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.
- Conventions for specifying the database path name
  When you access databases from the file system (instead of from the classpath or a jar file), any path name that is not absolute is interpreted as relative to the system directory.
- Special database access
  You can also access databases from the classpath/modulepath or from a jar file (in the classpath/modulepath or not) as read-only databases.
- Database connection examples
  The examples in this section use the syntax of the connection URL for use in an embedded environment.

Parent topic: Derby embedded basics
Related concepts
Derby JDBC driver
Derby JDBC database connection URL
Derby system
A Derby database
Working with the database connection URL attributes