Using the MyEclipse Derby Database Server

The embedded MyEclipse Derby database allows you to learn about database and persistence features in MyEclipse immediately, without spending time downloading, installing and populating a database yourself. In this tutorial, you will learn how to:

  • Start and stop the MyEclipse Derby server
  • Connect to the MyEclipse Derby server
  • Customize the server

1. Start the MyEclipse Derby Database Server

To start the embedded Derby server, click the drop-down arrow , and select MyEclipse Derby>Start.

MyEclipse Derby database
Starting Derby

A message in the Console view confirms the Derby database server startup.

Derby startup status message

To stop Derby, click the drop-down arrow , and select MyEclipse Derby>Stop.

Stopping Derby

As with startup, a shutdown confirmation message appears in the Console view.

Derby shutdown status message

Derby can also be controlled from the Servers view.

Controlling Derby from the Servers view

2. Connect to Derby Using the DB Browser

  1. Switch to the MyEclipse Database Explorer perspective by selecting Window>Show Perspective>MyEclipse Database Explorer.
  2. Start the Derby server.
  3. In the DB Browser, right-click the MyEclipse Derby driver, and select Open connection. 

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

You can use the embedded Derby database just like you would any other database in MyEclipse. For further details, refer to tutorials listed on the Database Development page.

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.

Connecting to Derby using the MyEclipse Derby driver

3. Configure the Embedded Derby server

To open the Derby configuration page, double-click the MyEclipse Derby server in the Servers view.

Configuring Derby

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

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

Restore MyEclipse Derby Driver: In case you change the port or have made other changes to the MyEclipse Derby driver that you want to undo, click this button. If the MyEcipse Derby driver does not exist, one is created.

Restore Sample Database: This creates/restored the sample myeclipse database at the specified Derby home folder. This operation destroys all changes made to any schema in the default myeclipse database. Please ensure Derby is shut down when attempting this operation.

Launching: By default, the MyEclipse Derby server starts when you open the JDBC connection. Disable the automatic server launch option if you require starting the server by other means before making the connection. You can also set the milliseconds to wait after server startup until the JDBC connection is made.

4. FAQ

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.

Can I connect to the same database from other MyEclipse installations or other workspaces?
Yes, all MyEclipse installations 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 that started the Derby server closes, the Derby server also shuts down.

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

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

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