IBM Db2
The IBM Db2 target writes data to an IBM Db2 database. For information about supported versions, see Supported systems and versions.
When you configure the IBM Db2 target, you specify the database name, host name, and port number. In addition, you can enable the target to use SSL. You can also use a connection to configure the target.
You specify tables to load the data into and the write mode the target uses to write data from record fields to table columns.
Before you use the IBM Db2 target, you must complete some prerequisite tasks.
Prerequisites
About this task
Before you configure the IBM Db2 target, complete the following prerequisite tasks.
Procedure
Specifying tables
You can use the IBM Db2 target to write to one or more tables.
- Single table
- To write data to a single table, simply enter the table name and schema name for the table.
- Multiple tables in a single schema
- To write data to multiple tables in a single schema, specify a field or header in the record that defines the table names as follows.
- Multiple tables in multiple schemas
- To write data to multiple tables in multiple schemas, specify fields or headers in the record that define the table and schema names as follows.
Use the Table Name and Schema Name properties on the Table tab to specify the tables to write to.
Key columns
When using merge or update write mode, you specify which set of key columns to use to compare records with rows in the database.
- Use the table primary keys
- The stage uses the table primary keys to configure the operations. Use this option when primary key columns are defined for the table.
- Use columns specified in the headers
- The stage uses key columns stored in the indicated record header attribute for the first record in a batch. Key columns must be listed as a JSON-formatted list or a comma-separated list. If the record header attribute is empty, the stage uses the table's primary keys.
- Use specified columns for each table
- Specify a set of key columns for each table. If the key columns property for a table is left empty, the stage uses the table's primary keys.
IBM Db2 data types
The IBM Db2 target converts Data Collector data types into IBM Db2 data types before loading data into the database.
| Data Collector Data Type | IBM Db2 Data Type |
|---|---|
| Boolean | SmallInt |
| Byte | SmallInt |
| Byte_Array | Binary, Binary_View, Fixed_Size_Binary, or Large_Binary depending on the original data type stored in metadata |
| Char | Vargraphic |
| Date | Date |
| Datetime | Timestamp |
| Decimal | Decimal |
| Double | Double |
| Float | Real |
| Integer | Integer |
| List | List, Large_List, Fixed_Size_List, List_View, or Large_List_View depending on the original data type stored in metadata |
| Long | BigInt |
| Map | Map or Struct depending on the original data type stored in metadata |
| Short | SmallInt |
| String | Vargraphic |
| Time | Time |
| Zoned_Datetime | Timestamp |
Troubleshooting IBM Connectivity Service
The target
connects to the database through IBM Connectivity Service. IBM Connectivity Service and all stages that use the service are bundled into
the IBM Connectivity Service stage library,
streamsets-datacollector-ibm-connectivity-service-lib. By default, Data Collector runs IBM Connectivity Service when the IBM
Connectivity Service stage library is installed.
| Call | CURL request |
|---|---|
| Get IBM Connectivity Service state |
curl --location 'https://<engine url>/rest/v1/flight/state' --header 'Authorization: Bearer <IBM Cloud API key> |
| Restart IBM Connectivity Service |
curl --location 'https://<engine url>//rest/v1/flight/restart' --header 'Authorization: Bearer <IBM Cloud API key> |
| Get IBM Connectivity Service logs |
curl --location 'https://<engine url>//rest/v1/flight/state' --header 'Authorization: Bearer <IBM Cloud API key> |
Configuring an IBM Db2 target
About this task
Configure an IBM Db2 target to write data to an IBM Db2 database.