DB2 is an IBM database product. It is a Relational Database Management System (RDBMS). DB2 is extended with the support of Object-Oriented features and non-relational structures with XML.
First download the DB2 JDBC driver.
Now register the driver in EXAOperation:
- Click "Software"
- Switch to tab "JDBC Drivers"
- Click "Browse..."
- Select JDBC driver file
- Click "Upload"
- Click "Add"
- In dialog "Add EXACluster JDBC driver" configure the JDBC driver (see below)
You need to specify the following settings when adding the JDBC driver via EXAOperation.
Parameter | Value |
---|---|
Name | DB2 |
Main | com.ibm.db2.jcc.DB2Driver |
Prefix | jdbc:db2: |
Files | db2jcc4.jar + license files |
Additionally, there are 2 files for the DB2 Driver:
db2jcc_license_cu.jar
- License File for DB2 on Linux Unix and Windowsdb2jcc_license_cisuz.jar
- License File for DB2 on zOS (Mainframe)
Make sure that you upload the necessary license file for the target platform you want to connect to.
- Create a bucket in BucketFS
- Upload the driver and the license to BucketFS
This step is necessary since the UDF container the adapter runs in has no access to the JDBC drivers installed via EXAOperation but it can access BucketFS.
Upload the latest available release of DB2 Virtual Schema to Bucket FS.
Then create a schema to hold the adapter script.
CREATE SCHEMA ADAPTER;
The SQL statement below creates the adapter script, defines the Java class that serves as entry point and tells the UDF framework where to find the libraries (JAR files) for Virtual Schema and database driver.
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtual-schema-dist-12.0.0-db2-3.0.0.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc4.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cu.jar;
/
;
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtual-schema-dist-12.0.0-db2-3.0.0.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc4.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cu.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cisuz.jar;
/
Define the connection to DB2 as shown below.
CREATE OR REPLACE CONNECTION DB2_CONNECTION
TO 'jdbc:db2://<host>:<port>/<database name>'
USER '<user>'
IDENTIFIED BY '<password>';
Below you see how a DB2 Virtual Schema is created.
CREATE VIRTUAL SCHEMA <virtual schema name>
USING ADAPTER.JDBC_ADAPTER
WITH
CONNECTION_NAME = 'DB2_CONNECTION'
SCHEMA_NAME = '<schema name>'
;
DB2 Data Type | Supported | Converted Exasol Data Type | Known limitations |
---|---|---|---|
BIGINT | ✓ | DECIMAL(19,0) | |
BINARY | × | ||
BLOB | × | ||
BOOLEAN | ✓ | BOOLEAN | |
CHARACTER | ✓ | CHAR | |
CLOB | × | ||
DATE | ✓ | DATE | |
DBCLOB | × | ||
DECIMAL | ✓ | DECIMAL | |
DECFLOAT | × | ||
DOUBLE | ✓ | DOUBLE PRECISION | |
GRAPHIC | × | ||
INTEGER | ✓ | DECIMAL(10,0) | |
SMALLINT | ✓ | DECIMAL(5,0) | |
TIME | ✓ | VARCHAR(100) | |
TIMESTAMP | ✓ | TIMESTAMP | |
REAL | ✓ | DOUBLE PRECISION | |
VARCHAR | ✓ | VARCHAR | |
VARBINARY | × | ||
VARGRAPHIC | × | ||
XML | ✓ | VARCHAR(2000000) |
LIMIT
is replaced byFETCH FIRST x ROWS ONLY
OFFSET
is currently not supported as only DB2 V11 support this nativelyADD_DAYS
,ADD_WEEKS
... will be replaced byCOLUMN + DAYS
,COLUMN + ....
In the following matrix you find combinations of JDBC driver and dialect version that we tested.
Virtual Schema Version | DB2 Version | Driver Name | Driver Version |
---|---|---|---|
2.0.0 | ibmcom/db2:11.5.7.0a | db2jcc | 11.5.7.0a |
2.1.0 | ibmcom/db2:11.5.8.0 | db2jcc | 11.5.8.0 |