Accessing databases from the classpath In most cases, you access databases from the file system. However, it is also possible to access databases from the classpath. The databases can be archived into a jar or zip file or left as is. Classpathaccessing databases from

All such databases are read-only.

To access an unarchived database from the classpath, specify the name of the database relative to the directory in the classpath. You can use the classpath subprotocol if such a database is ambiguous within the directory system. See for more information.

For example, for a database called sample in C:\\demo\databases, you can put the C:\\demo\databases directory in the classpath and access sample like this:

jdbc:derby:/sample

The forward slash is required before sample to indicate that it is relative to C:\\demo\databases directory.

If only C:\ were in the class path, you could access sample (read-only) like this:

jdbc:derby:/demo/databases/sample