Eclipse: an elegant IDE for MySQL

from the Artful MySQL Tips List

Why tie down your database development to one operating system when you don't have to? Why burden yourself with the pain of learning new development tools every time you move to a new RDBMS?

How would you like a free, powerful database IDE than runs everywhere Java runs? For a while, the "write once, run everywhere" promise of Java was undermined by two deadly problems---slow performance and inter-platform bugs. Those days are gone.

Eclipse, downloadable from, is a powerful, elegant, blazingly fast, multi-platform open source, database-ready IDE, written in Java. Download a build that suits your preferences. Installation is dead simple: unpack the archive into a folder of your choice, preserver directory structure. Once you have installed a current version of MySQL and its Connector/J, as described below, you can connect any Eclipse project to any available MySQL database. And, of course, you can connect to any other database for which you can find a JDBC driver.

Eclipse runs on Windows, *Nix and the Mac. There are custom versions for developing in Java, C, C++, PHP and other languages.

Getting started with Eclipse

There is a starter Eclipse tutorial at When you get to the end of the tutorial, though, you may be looking at an edit window with an empty class definition. If so, fill it out with a bit of code that can be compiled and run, for example ...

package org.jtdemo;

public class Demo {
  public static void main(String[] args) {
    System.out.println("Hello world!");

... then select File | Save to compile it, and Run | Run As ... | Java Application to run it.

GUI for databases

The SQLExplorer plugin for Eclipse provides an elegant UI for database development and maintenance using any valid JDBC database connector. Download the current SQLExplorer version from Close Eclipse if it is open. Install SQL Explorer by unpacking it over your Eclipse installation folder.

If you're a Windows user, you may be asking "What!? No MSI? No setup.exe? No registry updates?" Exactly. You're no longer locked into your operating system.

SQLExplorer and MySQL has a SQLExplorer tutorial at Beware that some Eclipse and SQLExplorer interface details and labels have changed since that tutorial was written. At least it provides an overview of how to get started.

For MySQL connectivity, download MySQL Connector/J from and unpack it into a folder named in your CLASSPATH.

The easiest way to get started with Eclipse and MySQL, after SQLExplorer is installed, is to run Eclipse, and from the menu select Window | Open Perspective | Other | SQLExplorer. This opens the SQLExplorer "perspective". Then from the Window menu select Preferences, click on SQL Explorer in the left panel of the window which opens, select JDBC Drivers, and check the driver list in the right panel for a MySQL entry. Edit it if it is there, else add it, setting Example URL to jdbc:mysql://localhost/test and Driver Class Name to com.mysql.jdbc.Driver. Click OK.

Now Connector/J is available to Eclipse. To prove that's so, click on the Connections heading in the Connections panel to create a new connection using the MySQL driver, fill in your user name and password, and open the connection. Instantaneously the Database Structure panel shows you a tree view of all your databases on the server you connected to, and the Database Detail panel shows detail for each database as you click on it.

Data modelling in Eclipse

Azzurri Data Modeler is a graphical data modelling tool that plugs into Eclipse. Currently it can be found at; if the link has changed, Google for 'Clay database modeling'.

Azzurri Clay Modeler needs the Eclipse Graphical Editing Framework (GEF), which can be found at Unpack the GEF archive over the Eclipse installation.

Download Clay Modeler from Install by unpacking the archive over the Eclipse installation. To verify your installation of GEF and the Clay Modeler, run Eclipse, select Help | Software Updates | Update Manager, and check that GEF and Clay are listed there.

Azzurri Clay has become one of our favourite free tools for designing and reverse engineering databases. Designing a database is beyond the scope of this article, but reverse engineering is simple:

1. Run Eclipse, from the menu select File | New | Project |General | Project, give your new project folder a name, and click Finish.

2. To make the project a database modelling project, from the menu select File | New | Other..., click on Database Modeling, and then on Clay Database Modeler. In the New Database Model dialog that now appears set SQL Dialect to MySQL 5.

3. An item named Clay now appears on the main Eclipse menu. Open it, select Reverse Engineer a Database, and a Connect dialog opens. Click on the Add New button, select MySQL from the Connection template dropdown; the dialog will populate the URL and JDBC Driver fields. In the URL, replace <host> with the host you are using (eg localhost), and replace <dbname> with the name of the database you wish to reverse engineer. Give the connection an appropriate Alias, fill in username and password, and click OK. Clay instantly produces a graphical model of your database.


Nothing's perfect. On any given day, about half the problems posted on the most-recent page of the Newcomers forum at have no reply. Don't expect reliable support typical of the MySQL user community.

Return to the Artful MySQL Tips page