Apache Derby Network Server
This is a tutorial that shows how to setup the Apache Derby Database as a Network Server and how to configure Eclipse and your JPA project accordingly.
Contents |
Introduction
Derby has two operation modes: Embedded and Network Server. Using the former one, only one Java Virtual Machine (JVM) at a time can access the database (if you are reading this tutorial, you probably have come across this issue during the practical software engineering course). The latter one allows more than one JVM, i. e. more than one program at a time to connect to the database using TCP networking. In this way, it is possible to test an application that uses a particular Derby database and at the same time leave the connection in the Eclipse Data Source Explorer open.
Part I: Setup and start the server
The following steps are valid for Windows, Linux and Mac OS X.
Installation
Download and unzip the latest official Derby release (currently db-derby-10.8.2.2-bin.zip
) from http://db.apache.org/derby/derby_downloads.html into a directory of your choice.
Start
The Derby Network Server is started via the command line:
$ cd path/to/db-derby-10.8.2.2-bin/lib $ java -jar derbyrun.jar server start
If everything is alright, the server starts and is now listening on port 1527. You can shutdown it using the keyboard combination Ctrl-C.
Part II: Configuring Eclipse and your JPA project
Eclipse Data Source Explorer
- Open the Eclipse Data Source Explorer View.
- Right-click Database Connections and select New... to create a new Database Connection Profile.
- Select Derby as Connection Profile Type and enter a meaningful name for the connection, e. g. Derby Network Server. Then proceed to the next page.
- If you can select Derby Client JDBC Driver from the combo-box, do that and proceed with step X. Else we will create this driver in the next step.
- Click the blue symbol next to the combo-box to create a new driver definition.
- From the list of driver templates, select Derby Client JDBC Driver. On the tab JAR List, specify the correct location for the
derbyclient.jar
file you unzipped in a previous step. Then click OK.