Connecting to a Derby database

To connect to a Derby database,
you need to perform the following steps:

Start the JVM

Load the appropriate driver.

Create a connection by providing a valid database connection URL.

When using ij interactively to connect to a Derby database
connection information is generally supplied on the full database connection
URL. ij automatically loads the appropriate driver based on the syntax of
the URL. The following example shows how to connect in this manner by using
the Connect command and the embedded driver:

Note: In these and subsequent examples the databases were
created in the derby.system.home directory. For more information
on the System Directory see the Derby Developer's Guide.

ij
provides alternate methods of specifying part or all of a connection URL (e.g.
the ij.protocol, ij.database,
or ij.connection.connectionName properties).
These properties are often used when a script is being used and the path to
the database or the driver name is not known until runtime. The properties
can also to used to shorten the amount of information that must be provided
with the connection URL. The following are some examples of different ways
to supply the connection information:

Supplying full connection information on the command line

Specifying
one of the following properties along with a valid connection URL on the ij
command line starts ij with the connection already active. This is often used
when running a SQL script so the database name or path can be specified at
runtime.

A default URL protocol
and subprotocol can be specified by setting the property ij.protocol or
using the ij Protocol command.
This allows a connection to be made by specifying only the database name.
This "short form" of the database connection URL defaults the protocol (For
more information, see About Protocols).

This
example uses the ij Protocol command
and a "short form" connection URL:

If you are using the drivers supplied
by Derby, you can specify
the driver names listed in JDBC drivers overview.
However, the Derby drivers
are implicitly loaded when a supported protocol is used so specifying them
is probably redundant. Specifying a driver is required when ij is used with
other JDBC drivers to connect to non-Derby databases.
To use drivers supplied by other vendors explicitly specify the driver one
of three ways