Connecting to a Derby database

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

Load the appropriate driver. Provide a database connection URL for the database. In ij, there are three ways of accomplishing these steps:
  • Full database connection URL

    ij can work with any JDBC driver. For drivers supplied by other vendors, you need to load the driver separately. For drivers supplied by , you can load the driver by specifying the full database connection URL in the connection. You do not need to load the driver explicitly in a second step.

    To connect, specify the full database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property.

    The protocol of the database connection URL must correspond to the driver provided by (see ) or, if you are using another driver, to that driver. The following example shows how to connect to a database by using the Connect command: D:>java org.apache.derby.tools.ij ij version 10.1 ij> connect 'jdbc:derby:sample'; ij>

  • Protocol and short database connection URL

    For drivers supplied by , specifying a protocol automatically loads the appropriate driver. You do not need to load the driver explicitly in a separate step. You specify a protocol with a property (ij.protocol or ij.protocol.protocolName) or command (Protocol).

    To connect, specify the "short form" of the database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property. A short form of the database connection URL eliminates the protocol (For more information, see ).

    D:>java org.apache.derby.tools.ij ij version 10.1 ij> protocol 'jdbc:derby:'; ij> connect 'sample'; ij> D:>java -Dij.protocol.myprotocolName=jdbc:derby: org.apache.derby.tools.ij ij version 10.1 ij> connect 'sample' protocol myprotocolName; ij>
  • Driver and full database connection URL

    If you are using the drivers supplied by , use the driver names listed in . The drivers are implicitly loaded when a supported protocol is used. Any other driver has to be explicitly loaded. You can load a driver explicitly with an ij property (ij.Driver), a system property (jdbc.drivers), or a command (Driver).

    To connect, specify the full database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property.

    D:>java org.apache.derby.tools.ij ij version 10.1 ij> driver 'sun.jdbc.odbc.JdbcOdbcDriver'; ij> connect 'jdbc:odbc:myOdbcDataSource'; ij>