Skip to content

Commit

Permalink
#440: Migrate DB2 virtual schema to its own repository
Browse files Browse the repository at this point in the history
  • Loading branch information
chiaradiamarcelo committed Jan 12, 2021
1 parent 4e5adc4 commit 180313b
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 1,283 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Running the Virtual Schema requires a Java Runtime version 9 or later.
[athena-dialect-doc]: doc/dialects/athena.md
[aurora-dialect-doc]: doc/dialects/aurora.md
[big-query-dialect-doc]: doc/dialects/bigquery.md
[db2-dialect-doc]: doc/dialects/db2.md
[db2-dialect-doc]: https://github.com/exasol/mysql-virtual-schema/blob/main/doc/user_guide/db2_user_guide.md
[exasol-dialect-doc]: https://github.com/exasol/exasol-virtual-schema/blob/master/doc/dialects/exasol.md
[hive-dialect-doc]: doc/dialects/hive.md
[impala-dialect-doc]: doc/dialects/impala.md
Expand Down
6 changes: 4 additions & 2 deletions doc/changes/changes_6.0.0.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Exasol Virtual Schemas 6.0.0, released 2021-XX-XX

Code name: Migrated Oracle dialect implementation to its own repository.
Code name: Migrated Oracle and DB2 dialect implementations to their own repository.

## Summary

Please we aware you can not create Oracle Virtual Schemas using this JAR anymore.
Please we aware you can not create Oracle nor DB2 Virtual Schemas using this JAR anymore.
Oracle dialect implementation has been migrated to https://github.com/exasol/oracle-virtual-schema.
DB2 dialect implementation has been migrated to https://github.com/exasol/db2-virtual-schema.

## Refactoring

* #438: Removed Oracle dialect implementation as it has been migrated to https://github.com/exasol/mysql-virtual-schema.
* #440: Removed DB2 dialect implementation as it has been migrated to https://github.com/exasol/db2-virtual-schema.

## Dependency updates

Expand Down
121 changes: 1 addition & 120 deletions doc/dialects/db2.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,3 @@
# DB2 SQL Dialect

[DB2](https://www.ibm.com/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.

## Registering the JDBC Driver in EXAOperation

First download the [DB2 JDBC driver](http://www-01.ibm.com/support/docview.wss?uid=swg21363866).

Now register the driver in EXAOperation:

1. Click "Software"
1. Switch to tab "JDBC Drivers"
1. Click "Browse..."
1. Select JDBC driver file
1. Click "Upload"
1. Click "Add"
1. 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`, `db2jcc_license_cu.jar` |

Additionally there are 2 files for the DB2 Driver.

* `db2jcc_license_cu.jar` - License File for DB2 on Linux Unix and Windows
* `db2jcc_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.

## Uploading the JDBC Driver to EXAOperation

1. [Create a bucket in BucketFS](https://docs.exasol.com/administration/on-premise/bucketfs/create_new_bucket_in_bucketfs_service.htm)
1. 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.

## Installing the Adapter Script

Upload the latest available release of [Virtual Schema JDBC Adapter](https://github.com/exasol/virtual-schemas/releases) to Bucket FS.

Then create a schema to hold the adapter script.

```sql
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.

### For Regular DB2 Servers

```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtual-schema-dist-8.0.0-bundle-6.0.0.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc4.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cu.jar;
/
;
```

### For Mainframes

```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtual-schema-dist-8.0.0-bundle-6.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;
/
```
## Defining a Named Connection

Define the connection to DB2 as shown below.

```sql
CREATE OR REPLACE CONNECTION DB2_CONNECTION
TO 'jdbc:db2://<host>:<port>/<database name>'
USER '<user>'
IDENTIFIED BY '<password>';
```

## Creating a Virtual Schema

Below you see how a DB2 Virtual Schema is created.

```sql
CREATE VIRTUAL SCHEMA <virtual schema name>
USING ADAPTER.JDBC_ADAPTER
WITH
SQL_DIALECT = 'DB2'
CONNECTION_NAME = 'DB2_CONNECTION'
SCHEMA_NAME = '<schema name>'
;
```

## Testing information

DB2 was tested with the IBM DB2 JCC Drivers that come with DB2 LUW V10.1 and V11. As these drivers didn't have any major changes in the past years any DB2 driver should work (back to V9.1). The driver comes with 2 different implementations `db2jcc.jar` and `db2jcc4.jar`. All tests were made with the `db2jcc4.jar`.

## Supported Capabilities

The DB2 dialect handles implements specific casts for time data types and functions.

## Casting of Data Types

* `TIMESTAMP` and `TIMESTAMP(x)` is cast to `VARCHAR` to not lose precision.
* `VARCHAR` and `CHAR` for bit data will be cast to a hex string with double the original size
* `TIME` will be cast to `VARCHAR(8)`
* `XML` will be cast to `VARCHAR(DB2_MAX_LENGTH)`
* `BLOB` is not supported

## Casting of Functions

* `LIMIT` will replaced by `FETCH FIRST x ROWS ONLY`
* `OFFSET` is currently not supported as only DB2 V11 support this natively
* `ADD_DAYS`, `ADD_WEEKS` ... will be replaced by `COLUMN + DAYS`, `COLUMN + ....`
The DB2 Virtual Schema has been migrated to its [own repository](https://github.com/exasol/db2-virtual-schema/).
6 changes: 4 additions & 2 deletions doc/user-guide/dialects.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Dialect name | Repository
[Athena][athena-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
[Aurora][aurora-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
[Big Query][big-query-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
[DB2][db2-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
[DB2][db2-dialect-doc] | [DB2 Virtual Schemas][db2-virtual-schema-repository] | [Latest release][db2-virtual-schema-releases] |
[Exasol][exasol-dialect-doc] | [Exasol Virtual Schema][exasol-virtual-schema-repository] | [Latest release][exasol-virtual-schema-releases] |
[Hive][hive-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
[Impala][impala-dialect-doc] | [Virtual Schemas][virtual-schemas-repository] | [Latest release][virtual-schemas-releases] |
Expand All @@ -25,7 +25,7 @@ You can also [develop a custom dialect](../development/developing-sql-dialect/de
[athena-dialect-doc]: ../dialects/athena.md
[aurora-dialect-doc]: ../dialects/aurora.md
[big-query-dialect-doc]: ../dialects/bigquery.md
[db2-dialect-doc]: ../dialects/db2.md
[db2-dialect-doc]: https://github.com/exasol/mysql-virtual-schema/blob/main/doc/user_guide/db2_user_guide.md
[exasol-dialect-doc]: https://github.com/exasol/exasol-virtual-schema/blob/master/doc/dialects/exasol.md
[hive-dialect-doc]: ../dialects/hive.md
[impala-dialect-doc]: ../dialects/impala.md
Expand All @@ -40,6 +40,8 @@ You can also [develop a custom dialect](../development/developing-sql-dialect/de

[virtual-schemas-repository]: https://github.com/exasol/virtual-schemas
[virtual-schemas-releases]: https://github.com/exasol/virtual-schemas/releases
[db2-virtual-schema-repository]: https://github.com/exasol/db2-virtual-schema
[db2-virtual-schema-releases]: https://github.com/exasol/db2-virtual-schema/releases
[exasol-virtual-schema-repository]: https://github.com/exasol/exasol-virtual-schema
[exasol-virtual-schema-releases]: https://github.com/exasol/exasol-virtual-schema/releases
[mysql-virtual-schema-repository]: https://github.com/exasol/mysql-virtual-schema
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 180313b

Please sign in to comment.