Computer Science Fundamentals Fall 2013 > Database Programming

Database Programming

Monday, December 2, 2013 - 6:10pm

Let's create a Apache Derby database.

On Mac, Linux, or Unix flavored systems:
export CLASSPATH=$DERBYDIR/lib/derby.jar:$DERBYDIR/lib/derbytools.jar
Please replace $DERBYDIR with the location where you uncompressed the Derby .zip (or .tar.gz) file.
export is a command for your shell (bash)

Create a database called gwudb. Do not type ij>. This indicate you are on the ij program.
ij> connect 'jdbc:derby:gwudb;create=true';

Create a table
ij> create table student ( gwid int, name varchar(20), phone varchar(5), addr varchar(15) );

Please respect the semicolon ;) Without that, the command will NOT execute at all.

Enter some data into the database (gwudb)
insert into student (gwid, name, phone, addr) values(111,'zhang','1-234','zhejiang');
insert into student (gwid, name, phone, addr) values(333,'cang','51','zhejiang').(444,'jiang','52','zhejiang') ;