MyEclipse Logo

MyEclipse Derby Database Server Tutorial

Table of Contents

download the latest MyEclipse version

help and support

1. Introduction

Welcome to the MyEclipse Derby Server Tutorial. In this tutorial we are going to show you how to start and stop the embedded Derby server, connect to it using the supplied driver and how to customize the server to suit your needs. A couple of sample schemas are also included. This embedded database will allow you to leverage and learn about database and persistence features in MyEclipse immediately, without incurring the overhead of downloading, installing and populating a database yourself.


2. Suggested Audience

This tutorial is intended for developers who are somewhat familiar with MyEclipse's Database Explorer feature set. If you have trouble understanding any Database Explorer features covered in this tutorial, feel free to browse through the Database Explorer tutorial.

To learn more about the topics presented in this tutorial, please have a look at the links in our Resources section. To get a better feel for MyEclipse and learning more about it, please check out our product Documentation for more material.

3. System Requirements

You will need MyEclipse installed to complete this tutorial.

However, if you notice portions of this tutorial looking different than the screens you are seeing, please let us know and we will make sure to resolve any inconsistencies.

4. Working with Derby

Starting Derby

To start the embedded Derby server, select MyEclipse Derby from the MyEclipse Server toolbar button, then select Start.

Figure 1. Starting Derby

You will see a status message from Derby in the Console view confirming the Derby server startup.

Figure 2. Derby startup status message

Stopping Derby

To stop Derby, select MyEclipse Derby from the MyEclipse Server toolbar button, then select Stop.

Figure 3. Stopping Derby

As with startup, a shutdown confirmation message will be seen in the Console view.

Figure 4. Derby shutdown status message

Derby can also be controlled from the Servers view.

Figure 5. Controlling Derby from the Servers view

Connecting to Derby with the Database Explorer

Switch to the MyEclipse Database Explorer perspective.
Please make sure Derby, is started and running before you attempt to connect to it. In the DB Browser view, right click the MyEclipse Derby driver and then select Open connection... to connect.

Note: If you do not see the MyEclipse Derby driver, see Restore MyEclipse Derby Driver in the following section.

You may use the embedded Derby database just like you would any other database in MyEclipse. For further details, refer to the Database Explorer tutorial.

MyEclipse Derby ships with a sample database named myeclipse. This database includes two sample schemas, CLASSICCARS and MYBLOG. Other schemas visible are Derby's system schemas.

Figure 6. Connecting to Derby using the MyEclipse Derby driver

Configuring the Embedded Derby server

To open the Derby preference page, select MyEclipse Derby from the MyEclipse Server toolbar button, then select Configure.

Figure 7. Configuring Derby

Alternatively, you can go to Window > Preferences > MyEclipse > Database Explorer > MyEclipse Derby to bring up the same page.

Figure 8. MyEclipse Derby Preferences

An explanation of the preferences is presented below:

Home Directory: This is the location at which Derby will store its databases. A folder with the name of your database will be created within the specified location. By default, the home directory is set to <user home>/.myeclipse/derby

Port: This is the port at which the Derby network server will listen for incoming connections. By default, the port is set to the Derby default, 1527.

Restore MyEclipse Derby Driver: In case you change the Port or have made other changes to the MyEclipse Derby driver which you wish to undo, press this button. If the MyEcipse Derby driver does not exist, one will be created.

Restore Sample Database: This will create / restore the sample myeclipse database at the specified Derby home directory.

This operation will destroy all changes made to any schema in the default myeclipse database.
Please ensure Derby is shutdown when attempting this operation.

5. Conclusion

We hope this tutorial has given you a good idea of how the embedded Derby database may be used and customized as required. The integrated database and driver should help you get off the ground quickly, be it for learning to use MyEclipse or actually testing your application.

If you have any suggestions for us to help make improve the embedded Derby integration or make this tutorial more informative, please let us know.

Below we would like to provide you with some more information pertaining to the topic covered in this tutorial. We offer the FAQ section for quick references to common questions and the Resources section with links to other helpful resources online that you may want to become familiar. We realize we can't cover every question you may have in one tutorial, but between this tutorial contents and our additional learning resources we hope you are far on your way to feeling comfortable with the technology.

6. FAQ

This section will list some of the more common questions that can come up while performing the tasks outlined in this tutorial.

  1. Will any changes I make to the database be persisted across Eclipse sessions?
    • Yes, the changes are saved to disk at the Derby home directory location explained above.

  2. Can I connect to the same database from other MyEclipse installations or other workspaces?
    • Yes, all MyEclipse installations will start and connect to the same database unless configured otherwise. If the embedded Derby server is started in one instance of MyEclipse another simultaneously running instance of MyEclipse may also connect to it without starting the Derby server in that instance as well. Any other applications may also connect to this database.
      Be advised, if the MyEclipse instance which started the Derby server is closed, the Derby server will also shut down.

      Starting multiple Derby servers which point to the same database could cause database corruption and should be avoided.

  3. What is the significance of the username in the MyEclipse Derby driver?
    • The username is treated as your default schema. Any unqualified table references will be directed to the default schema. The default username is classiccars; ergo the default schema is the supplied CLASSICCARS schema.

  4. What password can I use?
    • Any non-empty string may be used as the password.

7. Resources

In this section we want to provide you with additional links to resources that supplement the topics covered in this tutorial. While this is not an exhaustive list, we do make an effort to point to the more popular links that should provide you with diverse, high-quality information.

8. Feedback

We would like to hear from you! If you liked this tutorial, has some suggestions or even some corrections for us please let us know. We track all user feedback about our learning material in our Documentation Forum.  Please be sure to let us know which piece of MyEclipse material you are commenting on so we can quickly pinpoint any issues that arise.