-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fd7cf1
commit 7fcead9
Showing
34 changed files
with
602 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# MySQL SQL Dialect | ||
|
||
[MySQL](https://www.mysql.com/) is an open-source relational database management system. | ||
|
||
## Registering the JDBC Driver in EXAOperation | ||
|
||
First download the [MySQL JDBC driver](https://dev.mysql.com/downloads/connector/j/). | ||
Select Operating System -> Platform Independent -> Download. | ||
|
||
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 | `MYSQL` | | ||
| Main | `com.mysql.jdbc.Driver` | | ||
| Prefix | `jdbc:mysql:` | | ||
| Files | `mysql-connector-java-<version>.jar` | | ||
|
||
IMPORTANT: Currently you have to **Disable Security Manager** for the driver if you want to connect to MySQL using Virtual Schemas. | ||
It is necessary because JDBC driver requires a JAVA permission which we do not grant by default. | ||
|
||
## 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 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. | ||
|
||
```sql | ||
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS | ||
%scriptclass com.exasol.adapter.RequestDispatcher; | ||
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-2.1.0.jar; | ||
%jar /buckets/<BFS service>/<bucket>/mysql-connector-java-<version>.jar; | ||
/ | ||
; | ||
``` | ||
|
||
## Defining a Named Connection | ||
|
||
Define the connection to MySQL as shown below. | ||
|
||
```sql | ||
CREATE OR REPLACE CONNECTION MYSQL_CONNECTION | ||
TO 'jdbc:mysql://<host>:<port>/' | ||
USER '<user>' | ||
IDENTIFIED BY '<password>'; | ||
``` | ||
|
||
## Creating a Virtual Schema | ||
|
||
Below you see how a MySQL Virtual Schema is created. | ||
|
||
```sql | ||
CREATE VIRTUAL SCHEMA <virtual schema name> | ||
USING ADAPTER.JDBC_ADAPTER | ||
WITH | ||
SQL_DIALECT = 'MYSQL' | ||
CONNECTION_NAME = 'MYSQL_CONNECTION' | ||
SCHEMA_NAME = '<schema name>'; | ||
``` | ||
|
||
## Data Types Mapping and Limitations | ||
|
||
- `TIME` is casted to `TIMESTAMP` with a format `1970-01-01 hh:mm:ss`. | ||
- Unsupported data types: `BINARY`, `VARBINARY`, `BLOB`, `TINYBLOB`, `MEDIUMBLOB`, `LONGBLOB`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ cd virtual-schemas/jdbc-adapter/ | |
mvn clean -DskipTests package | ||
``` | ||
|
||
The resulting fat JAR is stored in `virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-2.0.1.jar`. | ||
The resulting fat JAR is stored in `virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-2.1.0.jar`. | ||
|
||
## Uploading the Adapter JAR Archive | ||
|
||
|
@@ -46,8 +46,8 @@ Following steps are required to upload a file to a bucket: | |
1. Now upload the file into this bucket, e.g. using curl (adapt the hostname, BucketFS port, bucket name and bucket write password). | ||
|
||
```bash | ||
curl -X PUT -T virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-2.0.1.jar \ | ||
http://w:[email protected]:2580/bucket1/virtualschema-jdbc-adapter-dist-2.0.1.jar | ||
curl -X PUT -T virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-2.1.0.jar \ | ||
http://w:[email protected]:2580/bucket1/virtualschema-jdbc-adapter-dist-2.1.0.jar | ||
``` | ||
|
||
If you later need to change the bucket passwords, select the bucket and click "Edit". | ||
|
@@ -84,7 +84,7 @@ CREATE SCHEMA ADAPTER; | |
|
||
CREATE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS | ||
%scriptclass com.exasol.adapter.RequestDispatcher; | ||
%jar /buckets/your-bucket-fs/your-bucket/virtualschema-jdbc-adapter-dist-2.0.1.jar; | ||
%jar /buckets/your-bucket-fs/your-bucket/virtualschema-jdbc-adapter-dist-2.1.0.jar; | ||
%jar /buckets/your-bucket-fs/your-bucket/<JDBC driver>.jar; | ||
/ | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...bc-adapter/src/main/java/com/exasol/adapter/dialects/mysql/MySqlColumnMetadataReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.exasol.adapter.dialects.mysql; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Types; | ||
|
||
import com.exasol.adapter.AdapterProperties; | ||
import com.exasol.adapter.dialects.IdentifierConverter; | ||
import com.exasol.adapter.dialects.JdbcTypeDescription; | ||
import com.exasol.adapter.jdbc.BaseColumnMetadataReader; | ||
import com.exasol.adapter.metadata.DataType; | ||
|
||
/** | ||
* This class implements MySQL-specific reading of column metadata. | ||
*/ | ||
public class MySqlColumnMetadataReader extends BaseColumnMetadataReader { | ||
/** | ||
* Create a new instance of the {@link MySqlColumnMetadataReader}. | ||
* | ||
* @param connection JDBC connection through which the column metadata is read from the remote database | ||
* @param properties user-defined adapter properties | ||
* @param identifierConverter converter between source and Exasol identifiers | ||
*/ | ||
public MySqlColumnMetadataReader(final Connection connection, final AdapterProperties properties, | ||
final IdentifierConverter identifierConverter) { | ||
super(connection, properties, identifierConverter); | ||
} | ||
|
||
@Override | ||
public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) { | ||
switch (jdbcTypeDescription.getJdbcType()) { | ||
case Types.TIME: | ||
return DataType.createTimestamp(false); | ||
case Types.BINARY: | ||
return DataType.createUnsupported(); | ||
default: | ||
return super.mapJdbcType(jdbcTypeDescription); | ||
} | ||
} | ||
} |
Oops, something went wrong.