Derby in a Pinch

Quick guide to using the Derby database server.

Download Derby from http://db.apache.org/derby/derby_downloads.html.

Unzip the downloaded file in a folder. We will call the folder <DERBY>.

From the <DERBY>/bin folder, start the network server:

./startNetworkServer -h IP_ADDRESS

Where IP_ADDRESS is the address of the machine where Derby is running. This option will let a remote client connect to Derby. For example:

./startNetworkServer -h 192.168.71.96

Verify that the server is running:

./NetworkServerControl sysinfo -h 192.168.71.96

Connect to Derby using ij and do some work.

./ij

Enter this command to connect to a database:

connect ‘jdbc:derby://192.168.71.96:1527/MyDB;create=true’;

This will create a folder called MyDB under <DERBY>/bin and create a database there.

Create a table:

create table DUMMY (ID integer PRIMARY KEY, NAME char(128));

View the schema of the new table:

describe DUMMY;

Finish up work.

disconnect;
exit;

Shutdown the server:

./stopNetworkServer -h 192.168.71.96

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s