DBA > Job Interview Questions > DERBY Java Database FAQs

How to access databases from a jar file?

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

(Continued from previous question...)

How to access databases from a jar file?

t is possible to access databases from a jar file. The jar file can be, but does not have to be, on the class path.

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 class path before you start up Derby. You can access jarDB1 with the following connection URL

jdbc:derby:/jarDB1

To access a database in a jar file that is not on the class path, 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 class path. 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

(Continued on next question...)

Other Job Interview Questions