Configure the Apache Derby DB Network/Client Mode in 5 Minutes
It is very easy to use Apache Derby with the embedded JDBC driver. The disadvantage of this solution is that you can only open one connection at a time. If you are developing an application with data persistence, it is often helpful to monitor the database from a different application (e.g. the Data Source Explorer from Eclipse). If you are not interested in reading the administration guide (http://db.apache.org/derby/docs/dev/adminguide/) you can follow these simple steps to configure Derby for Network/Client Mode:
Step 1: Download Apache Derby
Download the bin distribution from: http://db.apache.org/derby/derby_downloads.html
Step 2: Install
Unpack the archive in an appropriate application directory.
Step 3: Create a database directory
For example: mkdir db_storage
Step 4: Set environment variables:
Set DERBY_HOME and add its bin directory to your system path. Also amend your CLATHPATH with the Derby jars.
For example on your mac:
export DERBY_HOME=/Users/.../Programme/db-derby-10.5.1.1-bin export PATH=$PATH:$DERBY_HOME/bin export CLASSPATH="$DERBY_HOME/lib/derbynet.jar:$DERBY_HOME/lib/derbytools.jar:\ $DERBY_HOME/lib/derbyclient.jar:$DERBY_HOME/lib/derby.jar:$CLASSPATH"
On Windows systems:
SET CLASSPATH="%DERBY_HOME%/lib/derbynet.jar;%DERBY_HOME%/lib/derbytools.jar;%DERBY_HOME%/lib/derbyclient.jar;%DERBY_HOME%/lib/derby.jar;%DERBY_HOME%;%CLASSPATH%"
(You probably want to put it in a script or batch.)
Step 5: Create the database
Open a terminal/shell/command prompt, change into the database directory (Step3) and start ij.
Type:
connect ‘jdbc:derby:simple;create=true’;
exit;
Step 6: Database Configuration
In your database directory create the file derby.properties.
Add the following lines:
derby.connection.requireAuthentication=TRUE derby.authentication.provider=BUILTIN derby.user.alice=mypass
Step 7: Start Derby
Type:
startNetworkServer
on your mac or
startNetworkServer.bat
on your Windows system.
Step 8: Create a user schema and add a table
Open a new terminal/shell/command prompt, change into the database directory and start ij.
Type:
CONNECT ‘jdbc:derby://localhost:1527/simple’ user ‘alice’ password ‘mypass’;
Create schema alice;
create table dummy (id int primary key, text varchar(20));
insert into dummy values (1, ‘eins’);
insert into dummy values (10, ‘zehn’);
insert into dummy values (100, ‘einhundert’);
exit;
Step 9: Connect from your IDE:
you can now use the derby jdbc network client driver to connect to your database.
Tags: Apache Derby, configuration, database, java

May 24th, 2009 at 7:34 pm
[...] Configure the Apache Derby DB Network/Client Mode in 5 Minutes 24.05.2009 | Posted in Computer World It is very easy to use Derby with embedded drivers. The disadvantage of this solution is that you can only open one connection at a time. If you are developing an application with data persistence, it is often helpful to monitor the database from a different application (e.g. the Data Source Explorer from Eclipse). If you are not interested in reading administration guides (http://db.apache.org/derby/docs/dev/adminguide/) you can follow these simple steps:Step 1: Download Apache DerbyDownload t View original post here: Configure the Apache Derby DB Network/Client Mode in 5 Minutes [...]
May 24th, 2009 at 9:15 pm
[...] Configure the Apache Derby DB Network/Client Mode in 5 Minutes [...]