Companion Notes on
Setting up and Using
Eclipse Data Tools Platform


Russell Bateman
last update: 1 March 2010

Similarly to the decision I took on re-inventing a tutorial on JavaServer Faces, I decided to follow one on the Eclipse Data Tools Platform Lars Vogel has done. Again, however, there are things to say that he has left unsaid. This is my attempt to help out the dummies among whom I am the oldest.

What is the Eclipse Data Tools Platform?

DTP simply provides integrated tools for creating, prototyping and maintaining databases directly from Eclipse for your project.

The use of DTP doesn't preclude using JDBC or Hibernate, JDBC or Hibernate via Spring, or any other approach or framework. It mostly obviates the need for external tools such as SQuirreL (a Java-based database viewer). You can "do it all" right from Eclipse (albeit in a separate perspective).

As pointed out in the tutorial, DTP contains connectors for lots of common databases. I don't know what price you pay for including DTP in your Eclipse installation. Perhaps I'll come back some day to warn of why you should not do it. For now, I find it convenient.

Pick up and begin Lars' tutorial at http://www.vogella.de/articles/EclipseDataToolsPlatform/article.html. Return to my notes here when something goes awry. If I had (or anticipated) the same problem, you'll find my notes here on how to solve it. I use Lars' numbering, however, if he ever changes it, then you'll have to look for other ways to link what I'm saying with what is a problem for you in his tutorial.

2.1. Installation of Eclipse DTP

Please follow my steps in the cartouche entitled "Adding software to Eclipse" instead of clicking around on the links given in the tutorial. Eclipse will sort out the requirements and dependencies for you. I feel that this is a better and more generalized approach than the one implied.

2.2. Download Apache Derby

I downloaded the latest copy of Derby I could and exploded the zip to my usual C:\Users\russ\dev\downloads whence I plan to consume it.



3. Create DTP Project

Here I was a little disappointed because of my WTP orientation. The tutorial calls for setting up a general project—not even a Java one. Still, you're a fool if you don't follow the tutorial and then get stuck later, so the first time, you have to make a show of humility.

The way the library is added to the project is just wrong-headed. It's better professionally to set up a library that can be consumed formally via Build Path -> Libraries. This is what the same author shows in how the JSTL JARs are set up for use in the tutorial on Eclipse, Tomcat and JavaServer Faces. See note on 3.3.

In my opinion based on a couple of years of cooperation with others writing code and producing JARs, plus consuming third-party including build-it-yourself open source libraries, it is not good to create a lib subdirectory in an Eclipse project and populate its contents by hand. Instead, it's better to make use of the concept of a "user library." Remember, however, I have worked 99% in Dynamic Web and Java Projects over that time.

Nevertheless, you should end up with precisely:



4. Configuration

Here you set up an embedded Derby driver. Derby is a really useful database for persistence as it has a tiny footprint compared to full-featured database managers such as MySQL and PostgreSQL—not to mention Oracle or Microsoft SQL. It's not the choice for professional use, but I worked on such a product that used it internally just for persistence and it was perfectly suited for that and very reliable.

Follow the instructions carefully. There are points where the tutorial doesn't say it all. For example, in the New Driver Definition dialog, I had two lines in the list including "derby.jar" and "C:\Users\russ\dev\workspace\de.vogella.dtp.example\lib\derby.jar" and could not get an activated OK button until I deleted (the shorter) one.



5.1. Create a new database connection

I had to choose Window -> Open Perspective -> Other... to find the Database Development perspective. This perspective is found in Eclipse ONLY if you have properly installed Eclipse Data Tools Platform.

This will add a new perspective to the workbench, one that you'll need to accommodate (for width) if you don't want to access some of your existing perspectives via a drop-down menu. Simply grab the end of the barely visible edge of the perspectives tab (see big red arrow in this illustration) and drag it to the left to make more room. (If you're like me, for years I never even noticed that you could do this until I accidently happened upon it.)

As the password for user "test" I chose to use "test" which seems appropriate given there are only 4 dots in the Password edit field. Next, click the Save password checkbox, then click on Finish. Eclipse took a pause for this action, seeming to hang in the process, but it shortly returned to life.



5.2. Create a new database connection

I found that my Database Connections folder in the explorer had a different appearance than the tutorial and also that it was already connected.



6. Using SQL statements

What is illustrated here skipped some, but it wasn't too hard to figure out how to get there. Here's some of what was missing. You right-click on the new scripts folder, choose New, then scroll way down until you reach SQL Development.

This next step of naming the script file reveals a lot of crap already in the list when the tutorial snapshot was taken and, at the time, an unfortunate and misleading visual artifact was allowed into the illustration. Here's mine (less encumbered). This is something that the author might catch and fix so it may be gone by the time you read this.

Click on Finish. A new file, myscript.sql is created. Remember, you can keep the statements in this file and carefully execute them just one at a time so you have a record of what you've accomplished.



7. Maintain data in a table

If you leave off the semicolon (except, apparently, for schema-creation), you will get an error. Remember this for executing statements if you leave earlier ones inside the script file.

Best is that you select the SQL statement you wish to execute, right-click the selection and choose Execute Selected Text. (Ignore the several status lines you see behind here—I was experimenting to find the best ways of doing things.)

The tutorial proceeds with editing the data. My workbench is very similar to the one described and illustrated in the tutorial.

There is no actual demonstration of direct data editing, but it's pretty obvious how to do it. This is easier for a quick fix than, say, writing an SQL statement that may or may not totally bork your table.

As far as exporting the data, I gave it a try. It comes out, as you might guess, in comma-separated values, line-by-line. You can import data that way also. This is very useful for transporting a database from host to host on which you reinstall Eclipse as well as for changing database manufacturers.

Disappointment

As hinted earlier, I am disappointed by no "token" logic undertaken in this demonstration. We are left to integrate the principles into real projects on our own. I'm thining of extending this tutorial into my original WTP Eclipse, JSP and Tomcat tutorial at some future point.

Still, what this tutorial teaches is very useful indeed and very difficult to get from anywhere else. I've tried other DTP tutorials to my great dismay for I mostly couldn't even get them to work.