Wednesday, May 18, 2011

Working with Microsoft SQL Server from Eclipse/CFBuilder

After attending the “Time Management for Developers” session at cf.Objective() I’m trying to use Eclipse more so I can stay focused in one IDE, rather then contining to switch between applications during my development workflow.  One of the things I would often do is switch between my code editor and my virtual server interface to use the Microsoft SQL Server Management Studio for writing SQL code.  I decided to change this by using the SQL Explorer perspective in Eclipse/CFBuilder to do this.

Here’s a quick run down on how to configure Eclipse/CFBuilder for this.

Download SQL Server JDBC drivers

Microsoft, as usual (IMHO), makes this confusing by having four different drivers listed on their download site for this.  In the end what you want is the sqljdbc4.jar file.

  • Download Microsoft SQL Server JDBC Driver 3.0
  • Extract the archive and locate the /enu/sqljdbc4.jar file
  • Copy this file to some location on your system that you can point Eclipse/CFBuilder to (I put it in a folder on my Dropbox folder)

Install SQL Explorer

  1. Open the Eclipse/CFBuilder program
  2. Select the Help menu > Install New Software….
  3. In the Work with text box, enter:  http://eclipsesql.sourceforge.net/
  4. Click the Add… button. In the dialog that shows, click OK (keep the name blank, it will be retrieved from the update site.)
  5. Check the box next to “SQL Explorer”.
  6. Click the Next button
  7. Follow the prompts to accept the terms of service and install the plugin.
  8. When the installation is complete, Eclipse prompts you to restart. Click Yes. Eclipse restarts. The plugin is installed

Configure SQL Explorer

  1. Open the Eclipse preferences (on the Mac these are under the Eclipse application menu in the top-left, then select Preferences)
  2. Scroll down the list on the left to expand “SQL Explorer” and select “JDBC Drivers”
  3. Under the “JDBC Drivers” on the right, select “Microsoft MSSQL Server JDBC Driver”, then click the “Edit” button
  4. Click on the “Extra Class Path” tab
  5. Click on the “Add JARs…” button
  6. Select the sqljdbc4.jar file you downloaded earlier
  7. Click the “List Drivers” button
  8. Click the “OK” button
  9. Click the “OK” button

Connecting to MS SQL Server

  1. Click on the “Window” menu, select “Open Perspective”, select “Other”
  2. Scroll down to select “SQL Explorer”
  3. In the “Connects” tab, click on the “Create New Connection Profile”
  4. Setup the connection information for your specific server and click the “OK” button to save your information.
  5. Click the “Open New SQL Editor” button

1 comment:

Ed said...

Great post - Thanks!