To access your data in an IBM Db2 database, create a connection asset for it.
IBM Db2 is a database that contains relational data.
Supported versions
IBM Db2 10.1 and later
Create a connection to Db2
If you have set up an integrated cloud service, select the service instance to automatically fill in the fields in the connection form. Confirm that all the fields are complete.
To create the connection asset, you need the following connection details:
-
Database
-
Hostname or IP address
-
Username and password
-
Port
-
Application name (optional): The name of the application that is currently using the connection. For information, see Client info properties support by the IBM Data Server Driver for JDBC and SQLJ.
-
Client accounting information (optional): The value of the accounting string from the client information that is specified for the connection. For information, see Client info properties support by the IBM Data Server Driver for JDBC and SQLJ.
-
Client hostname (optional): The hostname of the machine on which the application that is using the connection is running. For information, see Client info properties support by the IBM Data Server Driver for JDBC and SQLJ.
-
Client user (optional): The name of the user on whose behalf the application that is using the connection is running. For information, see Client info properties support by the IBM Data Server Driver for JDBC and SQLJ.
-
SSL certificate (if required by your database server)
Credentials
If you select Shared, enter your username and password for the server.
If you select Personal, you have two choices:
- Enter your username and password for the server.
- Select platform login credentials.
You can use this option only if the Db2 service is hosted on the instance of Cloud Pak for Data that you are connecting to.
For Private connectivity, to connect to a database that is not externalized to the internet (for example, behind a firewall), you must set up a secure connection.
Choose the method for creating a connection based on where you are in the platform
- In a project
- Click Assets > New asset > Connect to a data source. See Adding a connection to a project.
- In a catalog
- Click Add to catalog > Connection. See Adding a connection asset to a catalog.
- In a deployment space
- Click Import assets > Data access > Connection. See Adding data assets to a deployment space.
- In the Platform assets catalog
- Click New connection. See Adding platform connections.
Next step: Add data assets from the connection
Where you can use this connection
You can use Db2 connections in the following workspaces and tools:
Projects
- Cognos Dashboards (Cognos Dashboard Embedded service)
- Data quality rules (IBM Knowledge Catalog)
- Data Refinery (watsonx.ai Studio or IBM Knowledge Catalog)
- DataStage (DataStage service). See Connecting to a data source in DataStage. The IBM Db2 for DataStage connection gives you increased performance and more features such as before and after SQL statements and reject links. However, you cannot use the IBM Db2 for DataStage connection outside of the DataStage service.
- Decision Optimization (watsonx.ai Studio and watsonx.ai Runtime)
- Metadata enrichment (IBM Knowledge Catalog)
- Metadata import (IBM Knowledge Catalog)
- Notebooks (watsonx.ai Studio). Click Read data on the Code snippets pane to get the connection credentials and load the data into a data structure. See Load data from data source connections.
- SPSS Modeler (watsonx.ai Studio)
Catalogs
-
Platform assets catalog
-
Other catalogs (IBM Knowledge Catalog)
Data lineage
- Metadata import (lineage) (IBM Knowledge Catalog and IBM Manta Data Lineage)
- Data Virtualization service
- You can connect to this data source from Data Virtualization.
Running SQL statements
To ensure that your SQL statements run correctly, refer to the Structured Query Language (SQL) topic in the IBM Db2 product documentation for the correct syntax.
Configuring lineage metadata import for IBM Db2
When you create a metadata import for the Db2 connection, you can set options specific to this data source, and define the scope of data for which lineage is generated. For details about metadata import, see Designing metadata imports.
To import lineage metadata for Db2, complete these steps:
- Create a data source definition. Select IBM Db2 as the data source type.
- Create a connection to the data source in a project.
- Create a metadata import. Learn more about options that are specific to Db2 data source:
- When you define a scope, you can analyze the entire data source or use the include and exclude options to define the exact schemas that you want to be analyzed. See Include and exclude lists.
- Optionally, you can provide external input in the form of a .zip file. You add this file in the Add inputs from file field. The file must have a supported structure. See External inputs.
- Optionally, specify advanced import options.
Include and exclude lists
You can include or exclude assets up to the schema level. Each value is evaluated as a regular expression. Assets which are added later in the data source will also be included or excluded if they match the conditions specified in the lists. Example values:
mySchema
:mySchema
schema.mySchema[1-5]
: any schema with a name that starts withmySchema
and ends with a digit between 1 and 5.
External inputs
If you use external Db2 PL/SQL scripts, you can add them in a .zip file as an external input. You can organize the structure of a .zip file as subfolders that represent schemas. After the scripts are scanned, they are added under respective schemas in the selected catalog or project. The .zip file can have the following structure:
<schema_name>
<script_name.sql>
<script_name.sql>
replace.csv
The replace.csv
file contains placeholder replacements for the scripts that are added in the .zip file. For more information about the format, see Placeholder replacements.
Advanced import options
- Extract extended attributes
- You can extract extended attributes like primary key, unique and referential integrity constraints of columns. By default these attributes are not extracted.
Learn more
Parent topic: Supported connections