DBA > Job Interview Questions > DERBY Java Database FAQs

How to access databases from the class path?

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

How to access databases from the class path?

The databases can be archived into a jar or zip file or left as is.

All such databases are read-only.

To access an unarchived database from the class path, specify the name of the database relative to the directory in the class path. You can use the class path subprotocol if such a database is ambiguous within the directory system.

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

jdbc:derby:/sample

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

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

jdbc:derby:/demo/databases/sample

(Continued on next question...)

Other Job Interview Questions