Home

 

Creating a connection to the ITSOBANK database

To connect to the Derby ITSOBANK database using the New Database Connection wizard, do these steps:

Stop the WebSphere Application Server v7 if it is running and has accessed the ITSOBANK database for other chapters, as Derby only allows one connection.

Open the Data perspective by selecting Window Æ Open Perspective Æ Other. In the Open Perspective dialog, select Data and click OK. The Data perspective opens.

Locate the Data Source Explorer view, typically at the bottom left in the Data perspective.

In the Data Source Explorer, right-click Databases and select New.

In the New Connection wizard, do these steps (Figure | 1-1):

Clear Use default naming convention and type ITSOBANKderby as Connection Name.
For Select a database manager select Derby.
For JDBC driver select Derby 10.2 - Embedded JDBC Driver Default.
For Database location click Browse and locate C:\7672code\database\derby\ITSOBANK.
Leave the User name and Password fields empty, as derby database does not require authentication.
Select Create database (if required).
Click Test Connection, and a pop-up displays Connection succeeded. Click OK to close the pop-up.
Click Next.

Figure 11-1 New Connection: Connection Parameters

You can use filters to exclude data objects (such as tables, schemas, stored procedures, and user-defined functions) from the view. Only the data objects that match the filter condition are shown. We only want to see the objects in schema ITSO (Figure | 1-2):

Clear Disable filter.
Select Selection.
Select Include selected items.
From the schema list, select ITSO.
Click Finish.

Figure 11-2 New Connection: Filter

The connection is displayed in the Data Source Explorer. Expand ITSOBANKderby [Derby 10.3.1.4 ...] Æ ITSOBANK. The Schemas folder is marked as [Filtered]. Only one schema (ITSO) is listed, and the others are filtered (Figure | 1-3).

Figure 11-3 Connection with schema and tables in Data Source Explorer

The filter framework allows you to filter out the tables at a more granular level. Suppose we only want to see tables that start with the letter A. Expand the schema ITSO, right-click Tables and select Filter. In the Filter dialog, do these steps:

Clear Disable filter.
Select Expression.
In the Name section, select Starts with the characters and enter A.
Click OK.

Now you can only see two tables in the Database Explorer: ACCOUNT and ACCOUNT_CUSTOMER.

We have to use the four tables in later sections. To disable the filter, right-click Tables [Filtered] and select Filters, select Disable filter and click OK.

Note: You might see the following error in the Problems view:

Problem with driver "Cloudscape - Cloudscape Embedded JDBC Driver Default." (Error: Unable to locate JAR/zip in file system as specified by the driver definition: db2j.jar.)

This file is not shipped with RAD v7.5. You can remove the driver in the Preferences dialog:

Select Window Æ Preferences.

Select Data Management Æ Connectivity Æ Driver Definitions on the left.

Select Cloudscape - Cloudscape Embedded JDBC Driver Default and click Remove.

Click OK.

ibm.com/redbooks