DBA > Job Interview Questions > DERBY Java Database FAQs

Explain about Embedded Derby JDBC Database Conne

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

(Continued from previous question...)

Explain about Embedded Derby JDBC Database Connection URL

The standard Derby JDBC connection URL, which you can use for tasks besides connecting to a database, is

jdbc:derby:[subsubprotocol:][databaseName][;attribute=value]*

derby is always the subprotocol for connecting to a Derby database.

Subsubprotocol, which is not typically specified, determines how Derby looks for a database: in a directory, in a class path, or in a jar file. Subsubprotocol is one of the following:

* directory The default. Specify this explicitly only to distinguish a database that might be ambiguous with one on the class path.
* classpath Databases are treated as read-only databases, and all databaseNames must begin with at least a slash, because you specify them "relative" to the class path directory.
* jar Databases are treated as read-only databases. DatabaseNames might require a leading slash, because you specify them "relative" to the jar file.
jar requires an additional element immediately before the database name:
(pathToArchive)
pathToArchive is the path to the jar or zip file that holds the database.

You typically pass the connection URL as an argument to the JDBC DriverManager.getConnection method call. For example:

DriverManager.getConnection("jdbc:derby:sample");

(Continued on next question...)

Other Job Interview Questions