# Accessing databases from a jar or zip file

It is possible to access databases from a jar file. The jar file does not have to be on the classpath/modulepath.

Note: All such databases are read-only.

For example, suppose you have archived the database jarDB1 into a file called jar1.jar. This archive is in the classpath before you start up Derby. You can access jarDB1 with the following connection URL

    jdbc:derby:classpath:jarDB1

To access a database in a jar file that is not on the classpath/modulepath, use the jar subprotocol.

For example, suppose you have archived the database jarDB2 into a file called jar2.jar. This archive is not in the classpath. You can access jarDB2 by specifying the path to the jar file along with the jar subsubprotocol, like this:

    jdbc:derby:jar:(c:/derby/lib/jar2.jar)jarDB2

For complete instructions and examples of accessing databases in jar files, see Accessing a read-only database in a zip/jar file.

Parent topic: Special database access
Related concepts
Accessing databases from the classpath/modulepath