DBA > Job Interview Questions > DERBY Java Database FAQs

Examples: How to create new databases and access

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

(Continued from previous question...)

Examples: How to create new databases and access existing ones ?

* jdbc:derby:db1
Open a connection to the database db1. db1 is a directory located in the system directory.
* jdbc:derby:london/sales
Open a connection to the database london/sales. london is a subdirectory of the system directory, and sales is a subdirectory of the directory london.
* jdbc:derby:/reference/phrases/french
Open a connection to the database /reference/phrases/french.
On a UNIX system, this would be the path of the directory. On a Windows system, the path would be C:\reference\phrases\french if the current drive were C. If a jar file storing databases were in the user's class path, this could also be a path within the jar file.
* jdbc:derby:a:/demo/sample
Open a connection to the database stored in the directory \demo\sample on drive A (usually the floppy drive) on a Windows system.
* jdbc:derby:c:/databases/salesdb jdbc:derby:salesdb
These two connection URLs connect to the same database, salesdb, on a Windows platform if the system directory of the Derby system is C:\databases.
* jdbc:derby:support/bugsdb;create=true
Create the database support/bugsdb in the system directory, automatically creating the intermediate directory support if it does not exist.
* jdbc:derby:sample;shutdown=true

Shut down the sample database.
* jdbc:derby:/myDB

Access myDB (which is directly in a directory in the class path) as a read-only database.
* jdbc:derby:classpath:/myDB

Access myDB (which is directly in a directory in the class path) as a read-only database. The reason for using the subsubprotocol is that it might have the same path as a database in the directory structure.
* jdbc:derby:jar:(C:/dbs.jar)products/boiledfood

Access the read-only database boiledfood in the products directory from the jar file C:/dbs.jar.
* jdbc:derby:directory:myDB

Access myDB, which is in the system directory. The reason for using the directory: subsubprotocol is that it might happen to have the same path as a database in the class path.

(Continued on next question...)

Other Job Interview Questions