Apache Derby Network Server

From Salespoint 5
Revision as of 15:21, 22 November 2011 by Martin Morgenstern (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 listining 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

1. Open the Eclipse Data Source Explorer View.

2. Right-click Database Connections and select New... to create a new Database Connection Profile.

3. 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.

4. 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.

5. Click the blue symbol next to the combo-box to create a new driver definition.

Configuring the Persistence Unit

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox