Configuring Database Access in Eclipse 3.0 with SQLExplorer
by Deepak Vohra05/11/2005
SQLExplorer is an Eclipse IDE database plugin that may be used to connect to a database from Eclipse. The SQLExplorer plugin adds a graphical user interface (GUI) to access a database with SQL. With SQLExplorer, you can display the tables, table structure, and data in the tables, and retrieve, add, update, or delete table data. SQLExplorer can also generate SQL scripts to create and query tables. Thus, using SQLExplorer may be preferable to using a command-line SQL client. In this tutorial, we shall establish a JDBC connection with the open source MySQL database from Eclipse 3.0 with the SQLExplorer plugin.
This tutorial has the following sections:
- Overview
- Preliminary Setup
- Configuring SQLExplorer
- Accessing Database Data
Overview
The SQLExplorer plugin configures Eclipse for SQL client access to a database, by adding an SQLExplorer "perspective" to the IDE.
To demonstrate the SQLExplorer plugin, we shall create an example table in the open source MySQL database and establish a JDBC connection to the MySQL database from the Eclipse IDE. Next, we shall retrieve and display the example data in the SQLExplorer GUI SQL client. We shall also update and delete the example table data to demonstrate the different features of the SQLExplorer plugin.
Preliminary Setup
- Download and install Eclipse 3.02.
- Download the SQLExplorer file net.sourceforge.sqlexplorer_2.2.3.zip.
- Extract the SQLExplorer .zip file to the <Eclipse>/eclipse directory. <Eclipse> is the directory in which Eclipse is installed. This adds the features and plugins directories of the SQLExplorer plugin to the features and plugins directories in Eclipse.
- Restart the Eclipse IDE.
- Install the MySQL database.
- Download Connector/J, which is used to connect to the MySQL database via a JDBC driver contained in a .jar file.
- Log in to the MySQL database with as root with the command:
>mysql -u rootA password is not required for the root user. To log in to the database with a password, specify the command:
>mysql -u root -p - Connect to the
testdatabase, an example database instance, with the command:>use test - Create an example table in the
testdatabase. The example table,Catalog, is composed of ONJava articles. The SQL script to create the example table is listed below:CREATE TABLE Catalog(CatalogId INTEGER, Journal VARCHAR(25), Publisher Varchar(25), Date VARCHAR(25), Title Varchar(45), Author Varchar(25));INSERT INTO Catalog VALUES('1', 'onjava', 'OReilly', 'April 2005', 'Five Favorite Features from 5.0', 'David Flanagan');INSERT INTO Catalog VALUES('2', 'onjava', 'OReilly', 'Feb 2005', 'Introducing JBoss Remoting', 'John Mazzitelli');INSERT INTO Catalog VALUES('3', 'onjava', 'OReilly', 'March 2005', 'Aspect-Oriented Annotations', 'Bill Burke');
Configuring SQLExplorer
Having installed the SQLExplorer plugin, we shall configure the SQLExplorer plugin in the Eclipse 3.01 IDE. First, set the SQLExplorer perspective in the Eclipse IDE. Click on the "Open a perspective" button in the Eclipse IDE to open a perspective. Figure 1 illustrates the "Open a perspective" button.






