Apache Derby Network Server
(Zwischensicherung) |
(Improved Part I) |
||
Line 15: | Line 15: | ||
=== Start === | === Start === | ||
− | The Derby Network Server is started via the command line | + | The Derby Network Server is started via the command line. First, change to the directory where you have unzipped the file from the previous step. |
− | + | ||
$ cd path/to/db-derby-10.8.2.2-bin/lib | $ cd path/to/db-derby-10.8.2.2-bin/lib | ||
+ | |||
+ | The actual start command is: | ||
+ | |||
$ java -jar derbyrun.jar server start | $ java -jar derbyrun.jar server start | ||
+ | Tue Nov 22 19:36:54 CET 2011 : Security manager installed using the Basic server security policy. | ||
+ | Tue Nov 22 19:36:55 CET 2011 : Apache Derby Network Server - 10.8.2.2 - (1181258) started and ready to accept connections on port 1527 | ||
+ | |||
+ | If everything is alright, the server starts and shows a message similar to this one in the command-line window. As you can see, it is listening for incoming connections on port 1527. | ||
− | + | '''Note''': You can shutdown the server using the keyboard combination ''Ctrl-C''. | |
== Part II: Configuring Eclipse and your JPA project == | == Part II: Configuring Eclipse and your JPA project == |
Revision as of 18:41, 22 November 2011
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. First, change to the directory where you have unzipped the file from the previous step.
$ cd path/to/db-derby-10.8.2.2-bin/lib
The actual start command is:
$ java -jar derbyrun.jar server start Tue Nov 22 19:36:54 CET 2011 : Security manager installed using the Basic server security policy. Tue Nov 22 19:36:55 CET 2011 : Apache Derby Network Server - 10.8.2.2 - (1181258) started and ready to accept connections on port 1527
If everything is alright, the server starts and shows a message similar to this one in the command-line window. As you can see, it is listening for incoming connections on port 1527.
Note: You can shutdown the server 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.