DB2 Universal Database: The Database Explorer, Part 1 - Page 2
January 11, 2006
by Paul C. Zikopoulos, IBM Canada
Adding database connections to the Database Explorer
The Database Explorer window allows you to explore the schema within your databases. These databases do not have to be only DB2 UDB databases either. In fact, almost any database that you can access with a JDBC driver, you can access in this window, for example, SQL Server, Oracle, Apache Derby, IBM Cloudscape, Sybase, and of course, the DB2 UDB family.
To add a database connection to the Database Explorer window, perform the following steps:
1. Right-click anywhere in the Database Explorer window and select New Connection:
2. Select the Choose a DB2 alias radio button, type NEWSMPL in the Connection name field, and click Next, as shown below:
Select Choose a DB2 alias when you want to connect to a DB2 UDB database that is cataloged on your local DB2 client. You can select a JDBC driver supported by your DB2 client; however, you do not need to know the platform and version of your DB2 alias with this option because this information is determined at connection time.
If you select Choose a database manager and JDBC driver, you have to know the database manager, platform, and version of the local or remote database you want to connect to. You can select a JDBC driver supported by your database manager and identify all required connection information for that driver. This is the option you would select if you wanted to connect to a remote DB2 UDB database for which you do not have a cataloged connection, or if you wanted to connect to a non-DB2 UDB database, as shown below:
Note that the Finish button is now enabled. Rational Application Developer has enough information about your database connection to add it to the Database Explorer. Clicking Next allows you to further customize this database connection. For example, you can work with filters, define a default schema, and more.
3. Select the database alias of the database you want to connect to from the Alias drop-down box, and click Next. The rest of the fields are automatically filled in for you since the information can be retrieved from the local catalog directory.
The following figure shows how Rational Application Developer automatically discovered the databases on my system. Since it knows these are DB2 UDB databases, it is also able to generate the JDBC driver class, and knows the location of the JDBC driver. From here, Rational Application Developer subsequently builds the connection URL for you. This is all done without your intervention. You can click Browse to select another JDBC driver if you want.
The Specify connection parameters page also gives you the opportunity to test the database connection by clicking Test Connection. If the Use your operating system user ID and password check box is selected (and the user account you used to log on to your system is authorized to access the database), you do not have to specify a user ID and password for this connection.
4. Specify the filters that you want to apply to this database connection, and click Next. (For this series, you can accept the defaults.)
There are two phases to the Rational Application Developer filtering. For example, you can filter on any system objects and only include objects that reside in your specific schema, and then filter out objects from that qualifying set. This feature is very useful in large enterprise environments, especially those running popular enterprise resource planning (ERP) applications such as SAP, which have thousands of tables. Although Rational Application Developer maintains a cache of the schema under the Database Explorer window after a successful connection is made to the database, it does not make sense to populate it with objects that you do not need or have privileges for.
Of course, you can always modify the filter or remove it by altering the properties of the database connection when it is created. Furthermore, you can enable filters and disable them by selecting the Enabled check box. This allows you to save filters and apply them when needed perhaps when you are working on different projects. Finally, you can have the result schema qualify for enumeration based on all the filters defined, or conditions within multiple filters by selecting the appropriate radio button.
5. Specify the Java home directory for building Java routines and a default SQL schema (the defaults are all fine for this series), and click Next, as shown below:
If you are connecting to a DB2 UDB for z/OS database, you can additionally specify the package and build owners for this database connection. If you are not connecting to a DB2 UDB for z/OS database, these fields are unavailable, as shown in the preceding figure.
6. A summary of the database connection is presented. Review it, and click Finish.
When you click Finish, Rational Application Developer adds the database connection to the IDE, loads the JDBC meta data, and adds the database schema. During this time, a progress bar is displayed at the bottom of the Summary window. (Obviously, the amount of time it takes to create the connection and populate the cache depends on the size of the database and the number of objects that pass through the filter.)
7. When the connection is built, the Copy to Project window automatically opens. You can use this window to copy the schema into a project. For now, just click Cancel. I will cover this in a subsequent article.
Once you have finished these steps, you will see the new database connection added to the Database Explorer window, as shown below:
Repeat the steps in this section to add the SAMPLE database, if it is not already added, so your Database Explorer looks like the preceding figure.