Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Getting Started with DTP
Contents
Requirements
This page describes steps to get started with DTP 0.7 through 1.0 streams. We assume that you have installed the appropriate version of the Eclipse platform, EMF and GEF as described on the DTP download page for your specific DTP build. We also assume that you have downloaded Apache Derby version 10.x, and are generally familiar with it. Finally, we assume that you are familiar with using Eclipse features such as preference pages, editors, views, and so on.
Introduction
While DTP is not solely about databases, we have used relational databases as our primary set of examples through 1.0. Further, we have selected Apache Derby as our sample database. Therefore, this guide will show the basic steps required for connecting to, and working with, Apache Derby using DTP.
Connecting to Apache Derby
The following are the essential steps for connecting to Apache Derby using DTP.
Defining a Driver Template
- Once Eclipse+DTP is running, open the Preferences dialog and select Connectivity-->Driver Definitions:
Since this is the first time to create a driver definition, there will be no entries under Derby Embedded. Select Derby Embedded and click on Add, launching the driver definition wizard:
Select Derby Embedded JDBC Driver... for the version of Apache Derby you have, change the name of the driver name (if you wish), and click on OK. This opens the driver details dialog:
Clear the sample derby.jar location and point to the correct one for your Apache Derby install. An embedded Apache Derby database doesn't require a user name or password, so those properties can be left blank. You might want to alter the url to point to another location for the embedded database.
Creating a Connection Profile for Apache Derby Embedded
Once you have created an Apache Derby embedded driver definition, you can then use that as the basis to create a connection profile. Open the Perspective selection dialog in Eclipse, and choose the Database Development perspective. Once open, this perspective should look like the following:
The Data Source Explorer (DSE) is found on the lefthand side. Right click on the Databases category and select New. This opens the new connection profile wizard:
Select Derby Embedded Database and click Next. After you give the connection profile a name and, optionally, a description, a dialog will open where the driver definition is to be selected:
Drop the combo box and choose the Apache Derby driver definition that you previously created, and click on Finish. The connection profile has now been created.
Connecting to Apache Derby
With the connection profile in place, you are now ready to connect to the embedded Apache Derby instance. Expand the Databases node in the DSE, select the connection profile you created, right click, and select Connect. After a few moments (the initial contents for the database instance are being created), you should be able to expand into the connection profile an examine the contents of the embedded Apache Derby database. The following shows an example expansion set:
Using the Apache Derby Connection
The are a number of ways to use a connection in DTP. Below we will discuss two of the most common for relational databases. The first is to call a stored procedure in the database. We can do this with Apache Derby by expanding into the Stored Procedures node under the SYSIBM schema. As an example, let's choose the SQLTABLES stored procedure. Right click on it, and choose Run.... This causes the routine editor to open, and a dialog for input value entry. Leave the defaults in the input value dialog, and choose OK. The stored procedure is executed, and the output is shown in the SQL Results view:
You can also create a SQL file and run it against as given database instance. First, create an Eclipse project, and then add a SQL File (under the SQL Development category in the New.. wizards) to it (via the standard Eclipse New... wizard). (Note:You need to open the connection for the following to work correctly.) When the DTP SQL Editor opens, the first thing you'll want to do is define which database connection it should target. Right click in the editor and choose Set Connection Info. The following dialog appears:
Once the connection information is set, you will then get richer content assist (ctrl+space) in the editor for table and column names. You can try various SQL statements such as:
select * from SYS.SYSTABLES
and selecting Execute All from the editor's context menu. The results of the query will then appear in the SQL Results view. Notice that there is a lefthand pane in the SQL Results view. This is the execution history. For each statements (including stored procedures) that you execute, an entry and Eclipse launch configuration is added. This lets you quickly retest the execution, perhaps with slighly different values or settings (see the launch configuration dialog). As is standard with Eclipse launch configurations, you can rename or delete them as you wish.
Conclusion
While this guide only scratches the surface of DTP frameworks and tools, we believe that it will give you enough familarity with DTP to continue exploring it on your own. Please feel free to engage the DTP team with bug reports, feature requests, and general comments, since the strength of DTP depends on involvement from the community to a large extent.