In Part 1 of this series, I discussed how to use the Database Explorer view in the IBM Rational Application Developer for WebSphere Software (“Rational AD”) product to create and work with IBM DB2 Universal Database (“DB2 UDB”) for Linux, UNIX, and Windows database connections. In Part 2 (and the upcoming Part 3), I want to introduce you to the many capabilities provided by the Data Definition view in the Rational AD integrated development environment (“IDE”).
If you are planning to follow along in this article, you need to ensure you followed the steps in Part 1 to set up your DB2 UDB environment. You also need to connect to the NEWSMPL database from the Data Definition view. (You will know you have a connection if you are able to expand the NEWSMPL tree.) Additionally, you should ensure you are in the Data Perspective view in the IDE. Before working through the examples in this article, your Database Explorer view should look like this:
Moving from Exploration to Definition
In order to start building your data definition, or working with the database in a Java project (which I will cover in a subsequent part of this series), you need to import the schema objects from the Database Explorer into your Data Definition project.
As you may recall from Part 1, when you add a database connection to the Database Explorer view, Rational AD gives you the opportunity to do this automatically:
In Part 1, I asked you to click Cancel since I wanted to focus on the features of the Database Explorer view.
In this section, I show you how to create a project and import the data schema into it by performing the following steps:
1. Create a new project by clicking File–>New–>Project. The New Project wizard opens.
2. Select Project from the Simple folder and click Next, as shown below:
Note: You may need to select the Show All Wizards check box to see this project.
3. Type a name for your project in the Project name field and click Finish, as shown below:
You can see on this page that the Directory field is automatically filled in with a directory path to store the contents of this project. Rational AD did this because of the way I have set up my preferences. You can override this default directory and select your own by clearing the Use default check box and subsequently using the Browse button to navigate to a directory where you would like to store the contents of this project.
If you want to reference another project, you can click Next instead of Finish on this page, select a different project, and then click Finish.
For example, on my machine, I have other Rational AD projects containing classes and other objects that I might want to use. In this case, I need to create a project reference, as follows:
When the project is created, your Data Definition view will look similar to the following one. (Note that my IDE has some existing projects, but this series will focus on the DATABASEJOURNALSERIES project.)
Once you have a project, you need to import the schema for the database you want to work with into that project from the Database Explorer view. You can import the schema into any project by performing the following steps:
1. Right-click the database that you want to import into your project in the Database Explorer view and select Reconnect, as shown below:
2. Right-click the database once you have a connection to it (it will have a sign beside it when it is connected) and select Copy to Project, as shown below:
The Copy to Project wizard opens.
3. Use Browse to select the project into which you want to import the NEWSMPL database schema, and click Finish.
When the copy operation finishes, the Data Definition view (when expanded) should look similar to this:
Note that the contents of the project are in the directory you specified when setting up the project: