Activity 1: Run SQL using the Embedded driver

In this section the Derby database engine is loaded by the Derby IJ tool. The Derby embedded driver is used to create and connect to the database firstdb. A few basic SQL commands are demonstrated.

In preparation for performing this activity the environment variable DERBY_HOME needs to be set and an empty working directory (DERBYDBS) created. The DERBY_HOME variable defines the filesystem path to the root directory of the Derby installation. The DERBYDBS directory is where the files created during the activities are stored.

The example commands defining DERBY_HOME use the fictitious filesystem paths C:\derby for Windows examples and /opt/derby for UNIX examples. Be sure to adjust these commands so DERBY_HOME indicates the location of the Derby installation on the system being used. The following activity sequence shows

  1. Setting the DERBY_HOME environment variable.
  2. Creating the DERBYDBS work directory
  3. Changing the directory (cd) to the work directory
  4. Copying the SQL scripts that create the tables and data for toursdb from the Derby demo\programs\toursdb subdirectory into the DERBYDBS directory.
Open a command window and perform the following activity sequence:
On Windows platforms:

set DERBY_HOME=C:\derby



copy %DERBY_HOME%\demo\programs\toursdb\*.sql . 

On UNIX Korn Shell platforms:

export DERBY_HOME=/opt/derby



cp $DERBY_HOME/demo/programs/toursdb/*.sql . 

Important: A command prompt will be displayed after each command is executed. If an error is displayed please double check the spelling and reenter the command.