Aaron Saray

open source programmer,
web developer

entrepreneur, author
and musician

My Blog

contains PHP, Web and business/entrepreneurial related content. Please join in the conversation!

Exploring MySQL in Eclipse PDT

As you probably know by now, I’m a huge fan of Eclipse PDT. Well, I wanted to stop using MySQL GUI tools for a bit and explore Eclipse tools.

Get the SQL Explorer Plugin

The first thing to do is to get the Eclipse SQL Explorer plugin. You can get that at the update URL: http://eclipsesql.sourceforge.net/

Install this software like you normally would. Accept the license and you’re ready to go with the plugin. I would recommend letting Eclipse restart after the installation.

Eclipse Uses JDBC

Eclipse uses JDBC connections to connect to MySQL. You can get this on the MySQL connectors page: Connector

Simply unzip the connector into your Eclipse program directory and move on.

Open Eclipse

Next, Open eclipse (if its not already open.) First step is to choose the SQL Explorer perspective. This can be done by going to the Window menu, clicking Open Perspective and choosing Other. Then, select the perspective from the list.

Now, create a connection profile. This is done by clicking on the Create New Connection Profile link. From here, name your connection, choose your adapter and fill in the proper credentials. (If you’re not familiar with this style credentials, you can visit this website: http://www.connectionstrings.com

What if I can’t find my Driver in the list?

There is a good chance that the driver may not be in the list by default. Follow the following steps.

1) On the connection profile screen, click the ‘Add/Edit’ button 2) Select the MysQL driver in the list. 3) Click the Edit button on the right hand side. 4) If you do not see your driver in the list of Java Class Paths, click on the Extra Class Path tab. 5) Browse to find your most recent driver download and select that jar file. 6) Click on the list drivers button. com.mysql.jdbc.Driver should appear in the Driver Class Name box. If not, select it. 7) Click OK and then OK again to return to the connection profile box

Now you should be able to use the MySQL driver from the list.

Browsing the Database

After configuring the connection profile, you should see it in your list of connections. Once you expand it and double click the user, you will be prompted to enter your password (as well as choose some other connection profile options).

From here, you’re good to go! You can browse the databases in the Database Structure tab, you can edit SQL in the SQL Editor tab, etc.

This entry was posted in Eclipse PDT, IDE and Web Dev Tools, mysql and tagged , , . Bookmark the permalink.

8 Responses to Exploring MySQL in Eclipse PDT

  1. Nifty! Now if someone would come up with a Mac version of PDT that was actually usable I might jump on that. (I keep telling myself “the next version will work.” I used NetBeans for a few years and moved to Eclipse when I worked in Windows, but when I moved to Mac I found both to be incredibly unstable on that platform. My PHP/Perl/JS/HTML/CSS/MySQL workflow on Mac centers around jEdit and Sequel Pro, both of which are free and fairly minimal in resource usage.

    While it would be nice to have the integrated testing and built-in server that you can get with Eclipse PDT I have learned (for now) to live without it.

    I do occasionally (as in every time) try again when new Mac builds of Eclipse PDT or Aptana studio come out though, so I have a question about using the DB from Eclipse: does it have the capability to set up an SSH tunnel or is that something you would have to do yourself before opening the connection? (I ask because Sequel Pro will actually set up the SSH tunnel for you which makes it really handy and keeps me from closing everything down at the end of the day and forgetting that I have an open tunnel in a terminal somewhere – yeah, I can be an airhead.)

  2. Aaron says:

    I believe this version of the system would require you to set up the ssh connection first, unfortunately.

    I never really found netbeans good enough to solve my needs… also mac? eww eww. :-p

  3. Dave Gafni says:

    Hey Aaron,

    Thanks for the tutorial, but it isn’t working for me, and I’m having an amazing amount of frustration. Eclipse looks pretty cool, but…

    1) I downloaded and expanded mysql-connector-java-5.1.14.zip to the Eclipse folder. So now I have a new folder there.

    2) I open the SQL Explorer perspective and click on Create New Connection Profile. In the New Connection Profile window, there’s nothing in the Driver popup.

    3) I click on Add/Edit Drivers. That opens this window:
    http://screencast.com/t/XngsEBV5L

    At this point, I’m lost. I don’t see com.mysql.jdbc.Driver anywhere. If I select MySQL Driver in the list and click Edit I get this window:
    http://screencast.com/t/KsM6TX2Hl

    Any help GREATLY appreciated!!! Thanks!!!

    - Dave

  4. Aaron says:

    Hi Dave,

    I believe if you click on list drivers and it doesn’t appear, you have to goto the extra tab and add the location of your newly downloaded driver jar file there.

  5. Adam Shuy says:

    I failed in the last step: browsing the database. I am running wamp 2 on my Windows 7. And I store all MySQL data under the /wamp/bin/mysql/mysql5.0.15b/data folder. How can I connect to there. BTW the localhost go to /wamp/www.

  6. Adam Shuy says:

    Sorry, it’s working. I failed because I forgot to activate the wamp server.

  7. jayBee says:

    I have your SQL Explorer plugin installed and working in Eclipse Helios PDT. It works fine except that whenever I save an editor window it clears the code from the window and saves an empty file.
    Any suggestions as to how to fix this problem?

    TIA

  8. Shannara says:

    This is nice to poke around (read only) view the database, but does not allow you to do any real work..

    Is there an Eclipse plugin that actually allows you to do real work in mySQL? I’m talking about GUI DDL stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>