You've heard that Eclipse is more than a Java IDE; it's more like an
application container. The embedded nature of the Eclipse plugins makes
switching between tasks fast and efficient. Those of you working with
JDBC (...and who does not?) can install a database access plugin,
define connection bookmarks and start browsing the database with no
need for a proprietary database client.
QuantumDB
QuantumDB (SourceForge)
is a lightweight, open-source plugin for database access from Eclipse
(...did I mention that it also works?). The latest version of QuantumDB
at the time of this writing is 2.4.5.
Why would you want to access your database from Eclipse? Well, if
you already use Eclipse for Java development, it just makes life easier
to stay in the same environment for non-Java tasks. Besides, it is a
time-saver and a cool gadget. Oh, and it also lets you:
connect to databases using standard JDBC drivers
review schemas, tables, views and sequences
look up column, index and foreign key information
issue ad-hoc queries or other SQL statements against the database
manage, edit, and work with SQL files (*.sql)
issue updates, deletes, and inserts using simple, easy-to-use wizards
keep track of recently executed queries
manage your database connections by defining database bookmarks
QuantumDB supports various databases. Here is a brief list of the JDBC-complaint databases that you can connect:
Adabas
DB2
DB2 on AS400
HSQLDB
Informix
MySQL
Oracle
Pointbase
PostgreSQL
Sybase
Installation
Like any other Eclipse plugin, the installation of
this plugin is a bit complicated. You need to download the QuantumDB
zip file quantum2.4.2_e3.0.zip from
downloadand extract the archive to your ECLIPSE_HOME folder. You are done.
First Database Connection
OK, you finished the long installation, now it's time to test the plugin. This is also a little complicated:
Launch Eclipse.
Open Window | Open Perspective | Other
In the Select Perspective window select Quantum DB(See Figure 1 Open the QuantumDB perspective).
Click OK
Figure 1 Open the QuantumDB perspective
Now you should see a blank QuantumDB
perspective with four views. On the right-hand side of the perspective
there is the Database Bookmarks view. Right-click anywhere on this view
and select New Bookmark. New Bookmark window will open(SeeFigure 2 Add DB2 JDBC driver).
In the next steps you will add the JDBC driver suited for your
database. Since most folks are already familiar with MySQL, the
exercise will add a DB2 driver.
Click Add driver
In the following dialog, New JDBC Driver, click
Add External Jar
In
the Open dialog, change Files of type: to Zip Files (*.zip) and
navigate to your DB2 driver (jar or zip), in my case that's under
C:\sql\db2\db2java.zip. Click OK.
Back in the New JDBC Driver dialog, click Browse
From the three classes on the list, pick the first class (See Figure 3 Select driver class). Click OK.
Notice that Type is now DB2. If it is not, change it to DB2.
Click Finish
Your JDBC driver window should look like Figure 4 DB2 JDBC driver installed. Select the DB2 driver and click Next.
In the Connection details dialog, enter your username, password and database name. In my case I entered the following:
Userid: levent
Password: need2worry
Database name: test
Click Next.
Enter a bookmark name such as test
Click Next.
Select Show the default schema.
Click Finish.
Figure 2 Add DB2 JDBC driver
Figure 3 Select driver class
Figure 4 DB2 JDBC driver installed
In your Database Bookmarks view you should see your first connection, test . Right-click on the connection and select
Connect. Expand the database icon and tables. Double click on any table. See the results in the Quantum Table View (SeeFigure 5 QuantumDB table query).
Figure 5 QuantumDB table query
Type any query in the Quantum SQL Query Editor. Click the green arrow
on the upper right corner of the editor. Observe the query results in
the new pane inside the Quantum Table View (See Table 1 Simple select queryandFigure 6 Query results)
SELECT
* TBL_USER
where
USER_TYPE='U'
Table 1 Simple select query
Figure 6 Query results
Notice in the Database Bookmarks view, under the
Recent SQL Statements, QuantumDB keeps your queries, so that if you
need to go back, you find your queries easier. Time-saver!
This plugin, like any other Eclipse plugin, is always a work in progress. Thus, make sure to check for the upcoming versions.
System Information:
Windows 2000
JDK 1.4.2_03
Eclipse 3.0
QuantumDB 2.4.2
About the author
Levent
Gurses is a Washington, DC-based technology consultant. He is also one
of the co-founders of Jacoozi,
an integrated solutions provider based in Alexandria, VA. In his
professional life Levent helps clients overcome their J2EE challenges
and develop leaner and meaner software development practices. Most of
his free time goes in reading and motorcycle racing.