Exploring Your DB With Eclipse 101 (Including Derby DBs!)

Posted By : todd sharp Posted At : November 19, 2007 8:51 AM Posted In: Eclipse, Apache Derby

15

I started looking into the Apache Derby Embedded database late last week as an alternative for future open source projects. The first major issue I had with them was the lack of a GUI tool for managing my schema. I feel pretty comfortable with SQL but I still like having a query browser/server administrator that lets me quickly edit/add tables and columns with a graphical user interface.

At first I downloaded and tried SQuirreL since several folks had commented that that is what they use to manage a Derby DB. I personally was left a little disappointed. I decided to look a little further when I discovered the Eclipse Data Tools Platform (DTP) project. This project is still a bit new, but it seems to be a very good start for working with Derby DBs.

Here is a quick tool for getting started with DTP. First you'll have to download the plugin and install it. Please notice there are some other dependencies listed at the top of the download for each version! You must have those other plugins for this to work.

Once you've installed the plugins and restarted Eclipse you're ready to set up DTP to access a Derby DB.

First select Window -- Preferences -- Connectivity -- Driver Definitions. Within the Driver Definitions dialog scroll down to Derby, select the proper version and click 'Add':

At the next dialog scroll down and select 'Derby Embedded JDBC Driver' and choose OK.

Now you need to point DTP to the Derby JDBC driver. You'll find the driver that ships with CF8 under lib/. Your location will vary but it will be something like:

  • C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\derby.jar
  • or
  • C:\ColdFusion8\lib\derby.jar

First clear the existing driver (click 'Clear') then click 'Add' and navigate to the proper driver.

You're now ready to point DTP at an existing Derby DB - or use DTP to connect to and create a new Derby DB. First make sure you are in the Database Development perspective (not CFEclipse!) and then right click on Database and select 'New'.

Select Derby Embedded Database and choose Next.

Give your connection a name (and a description if you want) and click Next.

At the next screen give your database a name and choose a location where it will be stored. Note - if you select a location such as your desktop make sure you enter a folder name at the end of the path or your DB will not be created!

Check the Create Database (if required) button (if you are creating a new db that is). Enter login/password (write these down, you'll need them when setting up your CF DSN). Enter any other optional parameters and click Next/Finish. Your connection is now created.

Now right click your new connection and click Connect.

You can now navigate your schema via the Database Explorer.

My next post will show how to use the Database Explorer to create a table and how to set up your ColdFusion DSN to point to this new Derby DB.

Comments (15)

Jake Munson's Gravatar Very cool. I had tried SQuirreL as well, I don't think I could get it to run. I ended up doing everything with code, but I'll keep this in mind for next time.

todd sharp's Gravatar With SQuirreL you also have to point it at the derby jdbc driver - did you try that?

My problem with it was there is no GUI table editor (at least that I could find).

Jake Munson's Gravatar I can't remember what I tried, this was a while ago. I know I followed all the directions, and I kept getting path errors, or something like that.

John Farrar's Gravatar OK... there is not "Derby" database options to be selected. Is there a hidden step to find these?

Charlie Arehart's Gravatar I concur with John. I went about installing the DTP as discussed above, into a 3.2.2 Eclipse (got the versions mentioned on the DTP page EMF, DSO, and GEF) and dropped them into Eclipse. On restarting, I had the "connectivity" option in Preferences, and several DBs listed, but not Derby. Do we need to have installed Derby manually and separately from the embedded version in CF for this to find it?

todd sharp's Gravatar Hmmm...weird...

However, if you've got the latest DTP version (1.5.1) it does state that Eclipse 3.3.1 is a requirement.

http://www.eclipse.org/datatools/

todd sharp's Gravatar To answer your direct question Charlie, no, I did not install Derby outside of CF.

John Farrar's Gravatar I would guess the version of eclipse isn't the issue since my version is 3.3.1.1

It just doesn't show the derby libraries you show in your screen grabs.

Charlie Arehart's Gravatar @Todd, well, the download page for DTP shows that 3.2.2 is supported, even with 1.5.1 of the DTP, according to this:

http://www.eclipse.org/datatools/downloads.html

so that's what I did. But I mentioned being on 3.2.2 in case it might be a clue for anyone.

I might have upgraded to 3.3, but hearing John say he's there and has the same problem makes me wonder if that will really solve the problem. This is indeed curious that we're not seeing Derby listed where you did. Must be some difference somewhere. Perhaps others will chime in.

todd sharp's Gravatar Can you guys check this folder:

\eclipse\plugins\org.eclipse.datatools.source_1.5.1.200709251\src

And see if you see anything that mentions Derby?

Something like:

org.eclipse.datatools.connectivity.derby...

I'm guessing that is where the definitions are stored.

Oh...wait...I just remembered - Scott Stroz was having problems with this install too (we talked on IM) and he did an update through Eclipse and it fixed things for him. I don't remember if he was having this *exact* problem but give that a try first I'd say...

Help - Software Updates - Find and Install - check everything and update...

Charlie Arehart's Gravatar OK, well maybe we're getting somewhere. :-) I chose NOT to use the source version and just took the "no source" "end user" version. I also found that I couldn't use the "new local site" option in Find and Install even though they offered a zip file to download. (It had no site.xml.) And they don't offer a URL to to the install from using "new remote site", so I had to do the manual approach of copying the files into the Eclipse dir (bummer, but it seemed I had no choice, and of course backing it out is a hassle if you didn't implement some backup of that directory before installing, which I didn't--I really thought to!).

But yes, there are derby-based jars in the plug-ins dir, such as:

org.eclipse.datatools.connectivity.db.derby_1.0.0.200706071.jar
org.eclipse.datatools.connectivity.derby_1.0.0.200706071.jar

and a few others. That's why it surprised me that it's not showing up.

Perhaps using the source option would be different, and may well be the solution (but it sure seems one shouldn't expect that to make a difference, right?)

todd sharp's Gravatar I wouldn't expect there to be a difference either.

On a side note, which may also be worth blogging about, did you know that you can set up Aqua Data Studios for Derby? Right now it is just "Generic JDBC Support" - but it's something...

I hear they are working on adding Derby in a future release (which would give things like table editor, etc). Oh - and they give a free license to OS developers...

Charlie Arehart's Gravatar Hey Todd, about AquaData Studio, yep, I've noted that previously (and a few others) in my Derby resources/FAQ page:

http://carehart.org/resourcelists/derby_for_CFers/...

If people here haven't seen it, there's a lot there on using Derby as a CFer.

I also list it on my tools resource page:

http://carehart.org/resourcelists/tools_to_conside...

I've been a fan of Aquadata for a while, and some of the others I've listed on these pages.

Charlie Arehart's Gravatar As a follow up to the discussion in this entry about setting up query tools for use with Derby, I never thought to comment last year but it's worth stating: if one already uses either DW, CF Studio/HomeSite+,or Eclipse with the Adobe CF8 Eclipse Extensions, they can connect to any Derby DB setup in CF, without any further ado, and these tools all let you build SQL, view data in the databases, etc. They all are based on RDS, so they can even connect to a DSN setup in CF as "Apache Derby Embedded", which normally you couldn't connect to from an outside tool. Of course, if you don't have RDS on the machine where the DBs are installed, then you need to use some other tool.

That said, Todd, you showed using the DPT tool to connect to a Derby DB that you were creating from within that tool. Did you (or anyone here) ever try connecting from that tool to a DB that was configured as an Embedded Derby DSN in a running CF engine? I'd think you'd be unable to, and would need to switch to using the Apache Derby Client approach and running the Derby Network Server, to permit multiple clients to access the DB. (Lest anyone confuse things, this single client limitation of the embedded derby driver is not about multiple CF users, but rather just multiple Java clients--CF and some query tool--both accessing the DB at the same time.)

This is all something that trips people up frequently. I've updated the "getting started" resource I listed above, to discuss these and many other details: http://www.carehart.org/resourcelists/derby_for_CF...

Mark H. Morrison's Gravatar I was able to connect to the Derby embeded database that was loaded with CF 8