Database connection examples The examples in this section use the syntax of the connection URL for use in an embedded environment. Connecting to databases not directly in the system directory

For reference information about connection URLs, see "Syntax of database connection URLs for applications with embedded databases" in the or "Accessing the Network Server by using the network client driver" in the .

  • jdbc:derby:db1

    Open a connection to the database db1. db1 is a directory located in the system directory.

  • jdbc:derby:london/sales

    Open a connection to the database london/sales. london is a subdirectory of the system directory, and sales is a subdirectory of the directory london.

  • jdbc:derby:/reference/phrases/french

    Open a connection to the database /reference/phrases/french.

    On a UNIX system, this would be the path of the directory. On a Windows system, the path would be C:\reference\phrases\french if the current drive were C.

  • jdbc:derby:a:/demo/sample

    Open a connection to the database stored in the directory \demo\sample on drive A (usually the floppy drive) on a Windows system.

  • jdbc::c:/databases/salesdb jdbc:derby:salesdb

    These two connection URLs connect to the same database, salesdb, on a Windows platform if the system directory of the system is C:\databases.

  • jdbc:derby:support/bugsdb;create=true

    Create the database support/bugsdb in the system directory, automatically creating the intermediate directory support if it does not exist.

  • jdbc:derby:sample;shutdown=true

    Shut down the sample database. (Authentication is not enabled, so no user credentials are required.)

  • jdbc:derby:memory:myDB

    Access the in-memory database named myDB. The syntax for a client connection URL is different; see for details.

  • jdbc:derby:classpath:myDB

    Access myDB (which is directly in a directory in the classpath) as a read-only database.

  • jdbc:derby:jar:(C:/dbs.jar)products/boiledfood

    Access the read-only database boiledfood in the products directory from the jar file C:/dbs.jar.

  • jdbc:derby:directory:myDB

    Access myDB, which is in the system directory.