< Previous | Next >

Connecting to the DB2 SAMPLE database and managing the connection

In this lesson, you will connect to the DB2® SAMPLE database and explore the actions that are available for database connections.

The DB2 SAMPLE database connection is displayed in the Data Source Explorer as a found connection when you open the Data perspective. If the SAMPLE connection is not displayed, you can explicitly connect to this database with a wizard. You can view and modify preferences for database connections in the Preferences window.

  1. View preferences for database connections:
    1. Click Window > Preferences to open the Preferences window.
    2. Expand Data Management. On the DB2 Options preferences page, you can specify options for the DB2 alias connections that are created at startup. In this tutorial you will keep the default preferences.
      Screen shot showing the Data Management Preferences page as described.
    3. Click Cancel to close the preferences window.
  2. Connect to the DB2 SAMPLE database. This action assumes that the connection was automatically created and displayed in the Data Source Explorer when you started the product. If the SAMPLE connection was not found, skip to the next step to explicitly create a connection.
    1. Right-click the SAMPLE connection in the Data Source Explorer, and select Connect.
    2. In the Properties for SAMPLE window, enter a valid user ID and password, then click OK.
    The connection icon changes to indicate that the database is connected.
  3. Optional: If you do not see the SAMPLE database in the Data Source Explorer, explicitly create a connection to the database with the New Connection wizard.
    1. Click the New Connection Profile button on the Data Source Explorer toolbar.
      The New Connection Profile button
    2. On the Local tab, select DB2 for Linux®, UNIX®, and Windows®. The name of the database is SAMPLE by default.

      The wizard selects the default IBM® Data Server Driver for JDBC and SQLJ (JDBC 4.0) to connect to the database. This driver is included with the Optim™ Development Studio. If you wanted to use a different version of the JAR files for this version of the IBM Data Server Driver for JDBC and SQLJ driver, you would click the Edit the Location of the JDBC driver JAR files button [...] to change these settings.

      If you wanted to use a different version of the IBM Data Server Driver for JDBC and SQLJ driver, you could select it from the JDBC driver field. Before you select the versions that use Kerberos or LDAP security, you must configure your Kerberos or LDAP environment.

      You can also use the "Other Driver Default" driver setting to use a JDBC driver of your choice.

      Screen capture showing the first page of the New Connection wizard, as described.

      JDBC tracing is set on the Tracing page of the Connection URL details panel. JDBC tracing is useful for troubleshooting connection problems, but tracing is not enabled by default so that unnecessary log files are not generated. If you wanted to enable tracing, you would clear the Disable Tracing check box on the Tracing Options page, select which actions to trace (for example, connection calls or statement calls), and specify a file name for the log file.

      Screen capture showing the Tracing tab of the New Connection wizard, as described.

    3. Type a valid user ID and password.
    4. Click Next. The wizard verifies your connection information. If you entered an invalid user ID or password you see an error message, otherwise the Data Privacy Modeling page opens.
    5. Optional: On the Data Privacy Modeling page, associate this connection with an existing physical data model in a data design project. This association is typically used to enable icons in views for columns in the database, if these columns also correspond to columns in the model that have been annotated with data privacy information. These icons help you to quickly identify columns with associated data privacy policies. You can also use this association to generate an Optim interchange file that contains data privacy information when you are copying data objects.

      This tutorial does not explain data privacy modeling, so you can click Next.

    6. Optional: On the Filter page, specify filtering options for the connection.

      If you wanted to filter the objects that are loaded for the connection, you would clear the Disable filter check box. You can select Expression to specify a filtering expression, or you can select Selection to select specific objects from the tree.

      Tip:

      Adding connection filters improves performance and simplifies the display in the Data Source Explorer when you are connecting to large databases. In addition to JDBC filtering for connections, you can also set data object filters in the Data Source Explorer view.

      You can add JDBC filtering after you have already created a connection by right-clicking the connection in the Data Source Explorer and selecting Properties, then modifying the filter settings in the window that opens.

  4. Expand the database object, and browse the objects that are contained in the database. The Data Source Explorer displays data objects such as table spaces, schemas, and tables, and privilege objects such as users and groups.
  5. Optional: Export the database connection information to an XML file. You can use this feature to share database connection information among team members, or to populate the Data Source Explorer in a new workspace.
    1. Click the Export button (Export button) on the Data Source Explorer toolbar.
    2. In the window that opens, select the SAMPLE connection, specify a file name (for example, myDB2connection) and directory (for example, c:\temp).
      Screen capture showing the Export Connection toolbar icon on the Database Explore, as described.
    The file is saved to the directory that you specified. You can use this file to import the connection information to this workspace or another Optim Development Studio workspace.
  6. Optional: Import the database connection information from the file that you created in the last step.
    1. Click File > Switch Workspace to switch to another workspace.
    2. Click the Import button (Import button) on the Data Source Explorer toolbar.
    3. In the Import Connection Profiles window, browse to the file that you created in the previous step, and click Open.
    4. Click OK.

      The SAMPLE database connection is displayed in the Data Source Explorer in a disconnected state.

    5. Click File > Switch Workspace and browse to your original workspace.
  7. Save the database information offline. You can save database information so that you can view objects in a database connection even when you do not have an active connection. You can also use the saved information to develop data objects in a data development project.
    1. Right-click the SAMPLE database connection in the Data Source Explorer.
    2. Select Save Offline.
      Attention: This action can take a long time for large databases.
      A progress window opens to indicate that the database information is being saved.
    Now you can use the saved information to work offline. Some actions, such as dropping data objects, cannot be performed with an offline connection.
  8. Right-click the SAMPLE database connection again, and select Work Offline. You can browse the database objects in the disconnected database connection, and view their properties in the Properties view.
  9. Reconnect to the SAMPLE database by right-clicking it and selecting Connect.
< Previous | Next >

Feedback