Java Reference
In-Depth Information
7.
At the
ij>
prompt type
connect 'jdbc:derby:books;create=true;user=deitel;
password=deitel';
and press
Enter
to create the
books
database in the current directory and to create
the user
deitel
with the password
deitel
for accessing the database.
8.
To create the database table and insert sample data in it, we've provided the file
address.sql
in this example's directory. To execute this SQL script, type
run 'books.sql';
Once you create the database, you can execute the SQL statements presented in
Section 24.4 to confirm their execution. Each command you enter at the
ij>
prompt must be terminated with a semicolon (
;
).
9.
To terminate the Java DB command-line tool, type
exit;
10.
Change directories to the
addressbook_example
subfolder of the
ch24
examples
folder, which contains the SQL script
addressbook.sql
that builds the
address-
book
database. Repeat Steps 6-9. In each step, replace
books
with
addressbook
.
You're now ready to execute this chapter's examples.
After setting the
JAVA_HOME
environment variable, perform the following steps:
1.
Open a Terminal, then type:
DERBY_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/
Contents/Home/db
and press
Enter
. Then type
export DERBY_HOME
and press
Enter
. This specifies where Java DB is located on your Mac.
2.
In the Terminal window, change directories to the JDK installation folder's
db/
bin
folder. Then, type
./setEmbeddedCP
and press
Enter
to set the environment
variables required by Java DB.
3.
In the Terminal window, use the
cd
command to change to the
books_examples
directory. This directory contains a SQL script
books.sql
that builds the
books
database.
4.
Execute the following command (with the quotation marks):
$JAVA_HOME/db/bin/ij
to start the command-line tool for interacting with Java DB. This will display the
ij>
prompt.
5.
Perform Steps 7-9 of Section 24.5.1 to create the
books
database.
6.
Use the
cd
command to change to the
addressbook_example
directory. This direc-
tory contains a SQL script
addressbook.sql
that builds the
addressbook
database.