> ## Documentation Index
> Fetch the complete documentation index at: https://docs.textql.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IBM Db2

> Connect to IBM Db2 for Linux, UNIX and Windows or mainframe z/OS.

> [!WARNING]
>
> This connector requires the IBM Data Server Driver for ODBC and CLI on your deployment. Validate connectivity against your server before production use. IBM i is not supported by this connector.

## Prerequisites

* A reachable DRDA endpoint and a database name (LUW) or DDF location name (z/OS).
* A dedicated account with SELECT access to the intended tables and read access to the system catalogs. Remove write privileges and access to routines that modify data. The connector requests IBM's `ReadOnlyConnection` mode for reads; database grants remain required. The separate `SQL_ATTR_ACCESS_MODE` attribute is advisory.
* The IBM driver, its runtime libraries, and any required Db2 Connect entitlement. Mainframe licensing depends on the server and client installation; confirm it with your IBM administrator.

The deployment operator installs the complete IBM ODBC/CLI driver tree and sets `DB2_ODBC_DRIVER` to the absolute path of `libdb2.so` in the compute container. Keep IBM's dependencies and any license files in their supported locations. Nix builds use `db2_odbc`; Docker builds enable ODBC through `teradata_odbc`. Both require unixODBC. The connector does not redistribute IBM binaries or licenses.

## Add the connector

1. Open **Connectors**, add a database connector, and select **IBM Db2**.
2. Select **LUW** or **Mainframe (z/OS)** to choose the matching system catalog.
3. Enter the host, DRDA listener port, database or location, username, and password. Common non-TLS ports are 50000 for LUW and 446 for z/OS; use the listener port provided by your administrator.
4. Enter the schema names, separated by commas. Match their catalog case, usually uppercase. This list limits schema discovery; database grants control query access.
5. Keep **Use TLS** enabled for certificate and hostname validation. Configure private CA trust in the IBM driver when needed.
6. Test the connection, then save it.

## Queries and metadata

Tables, views, columns, types, and nullability are discovered from `SYSCAT` on LUW and `SYSIBM` on z/OS. Table previews use schema-qualified names and `FETCH FIRST` limits. Passwords use the existing connector encryption and redaction.

Write native Db2 SQL. Read-only query verification accepts a single SELECT or set query, checks nested writes, and rejects syntax it cannot verify. Common trailing Db2 isolation/read-only clauses are supported.

Table previews cast DECIMAL/NUMERIC columns to text using catalog types, preserving their exact digits. Native queries use the same upstream ODBC driver as Teradata, which returns uncast DECIMAL/NUMERIC values as floating point. For exact values in native queries, cast the final decimal expression, for example `SELECT CAST(SUM(AMOUNT) AS VARCHAR(64)) AS TOTAL FROM CLAIMS.PAYMENTS`. Keep arithmetic in Db2 before the final cast.

Character values use the upstream driver mappings; binary values that are not valid UTF-8 are returned with a `base64:` prefix. Results exceeding 50,000 rows or 64 MiB return an error asking for a smaller result.

Automatic PostgreSQL-to-Db2 conversion, automatic sample generation, primary-key discovery, foreign-key discovery, and automatic row counts are not supported in this version.

## Troubleshooting

* **Driver unavailable:** verify the absolute driver path and that the compute process can load all IBM runtime libraries.
* **SQL1598N or a license error:** ask your IBM administrator to verify the Db2 Connect entitlement and installation.
* **Certificate error:** verify the TLS port, certificate hostname, and IBM driver trust configuration.
* **No tables:** verify the platform, schema spelling, and catalog and table privileges.

See IBM's [ODBC/CLI connection guide](https://www.ibm.com/docs/en/db2/12.1.x?topic=cli-connecting-databases) and [connection attribute reference](https://www.ibm.com/docs/en/db2/11.5.x?topic=attributes-connection-list).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.