Adding a database mapping output

Before you start:

Before you use any mappings that you create, ensure that any databases that you have defined are correctly registered with ODBC on your computer.

You can add a database mapping output (target) from the Resource Navigator view in two different ways, depending on whether you are adding the database to the workspace for the first time or if the database has been imported previously and is in the workspace.

  1. To add the database to the workspace for the first time:
    1. Open the relevant mapping file in the Message Flow Mapping editor.
    2. Right-click anywhere in the white space of the Target pane.
    3. Select Add RDB Table Mapping Output from the pop-up menu. The Add Database Table Schemas window appears.
    4. Select the radio button entitled Import and Add Table Schemas from a Database, and click Next. The Database Connection window appears.
    5. Enter the database name, user ID, password, database vendor type, JDBC driver, and the class location of db2java.zip.
    6. Click Next. The Database Table Selection window appears.
    7. Select the table that you want to use and then enter the Place in Folder, if you know it, or click Browse and select it from the displayed list.
    8. Click OK and then Finish. The previously-selected table appears in the target view.
  2. To add a database that has been imported and is in the workspace:
    1. Open the relevant mapping file in the Message Flow Mapping editor.
    2. Right-click anywhere in the white space of the Target pane.
    3. Select Add RDB Table Mapping Output from the pop-up menu. The Add Database Table Schemas window appears.
    4. Select the first radio button, entitled Add Database Table Schemas from Workspace, and click Next. The Select Database Table Schemas window appears.
    5. Expand the view if necessary and select the tables that you want to use in the Target view.
    6. Click Finish. The table selected previously appears in the Target view.

If you cannot import the database definition, have your database administrator export the schema files for you to use.

Importing database schema files using the Data perspective

You can also import database schema files using the Data Perspective.

  1. Use the Data perspective to connect to the database, as described in Connecting to databases using the Data perspective.
  2. In the DB Servers view of the Data perspective, expand that database connection that you have created to display the database table.
  3. Right-click the database table and select Import to folder.
  4. Provide the name of a folder that exists in the message flow project.
  5. Return to the Broker Application Development perspective and reopen the mapping file in the Message Flow Mapping editor.
  6. Right-click anywhere in the white space of the Target pane and select Add RDB Table Mapping Input from the pop-up menu.
  7. Select the radio button entitled Add database table schemas from workspace and select the appropriate table from the list.

Database table names

By default in mappings, database table names are identified by the broker default schema and are in the format:
Database.table_name
However, if you define a schema for your application and define tables within the schema, you must prefix the table names with the schema name to produce the following format:
Database.schema_name.table_name
To do this:
  1. Right-click the database table in the Target pane and select Set RDB Schema Name from the pop-up menu.
  2. Select one of the three options:
    • Use default runtime schema for this data source produces the format:
      Database.table_name
    • Use schema name in table definition produces the format:
      Database.schema_name.table_name
      where schema name is obtained from the RDB table xmi file.
    • Use name specified produces the format:
      Database.user_specified_schema_name.table_name
  3. Click OK to save your changes.

Defining the schema name for an individual table, as described above, overrides the global definition in the Preferences dialog (see Defining the schema name).

Note: Do not rename the .tblxmi file, or you will have to re-map everything.
Related reference
Mappings