Creating a Derby database and running SQL statements
Getting Started with Derby
23
Operating
System
Command
UNIX (Korn Shell)
cp $DERBY_HOME/demo/programs/toursdb/*.sql .
Windows
copy %DERBY_HOME%\demo\programs\toursdb\*.sql .
> Important: Include the dot (
.
) at the end of the command so that the files are
copied to the correct location.
5. Verify that the files were copied to the
DERBYTUTOR
directory, as shown in the
following table.
Table 12.
Command to verify that the files were copied
Operating
System
Command
UNIX (Korn Shell)
ls DERBYTUTOR
Windows
dir DERBYTUTOR
Creating a Derby database and running SQL statements
Now, you will use the Derby
ij
tool to load the Derby database engine. You will use the
Derby embedded driver to create and connect to the
firstdb
database. You will also
use a few basic SQL statements to create and populate a table.
1. Run the Derby
ij
tool.
If you included the
DERBY_HOME/bin
directory in your PATH environment variable,
type:
ij
Otherwise, you can use the
java
command to start the
ij
tool, as shown in the
following table.
Table 13.
Command to start the
ij
tool
Operating
System
Command
UNIX (Korn Shell)
java -jar $DERBY_HOME/lib/derbyrun.jar ij
ij version 10.8
Windows
java -jar %DERBY_HOME%\lib\derbyrun.jar ij
ij version 10.8
2. Create the database and open a connection to the database using the embedded
driver.
CONNECT 'jdbc:derby:firstdb;create=true';
Description of connection command:
connect
The
ij
command to establish a connection to a database. The Derby
connection URL is enclosed in single quotation marks. An
ij
command can
be in either uppercase or lowercase.
jdbc:derby:
The JDBC protocol specification for the Derby driver.
firstdb