Load data from DB2

This article explains how to connect to a DB2 database with Exasol and then load data.

To view details about data type mappings or to migrate data, see the DB2 to Exasol migration script in our GitHub repository.

Prerequisites

  • The DB2 system must be reachable from the Exasol system.

  • The user credentials in the connection must be valid.

Download driver

Download the compatible JDBC driver from the IBM Support page.

Add JDBC driver

To add the JDBC driver, create a configuration file called settings.cfg with the following settings:

DRIVERNAME=DB2
PREFIX=jdbc:db2:
FETCHSIZE=100000
INSERTSIZE=-1

Follow the procedure described in Add JDBC Driver to upload the settings.cfg configuration and JDBC driver files to Exasol.

With some driver versions you may receive an error message indicating file permission issues. In this case you may have to disable the security manager by adding the line NOSECURITY=YES in the configuration.

Create connection

To create a connection, run the following statement. Replace the connection string and credentials as needed.

CREATE OR REPLACE CONNECTION JDBC_DB2
    TO 'jdbc:db2://192.168.99.100:50000/sample'
    USER 'db2inst1'
    IDENTIFIED BY 'exasol123';

To test the connection, run the following statement.

select * from 
(
import from JDBC at JDBC_DB2
statement 'select ''Connection works'' from SYSIBM.SYSDUMMY1'
);

Load data

Use IMPORT to load data from a table or SQL statement using the connection that you created.