Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

MySQL datatypes mappings and conversions: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html


Connecting Securely Using SSL
Configuring Connector/J client to use SSL can be accomplished by the following steps:
1) Import server certificate into the Java default truststore (although tampering the default truststore is not recommended) or by importing it into a custom Java truststore file. Use 'trustCertificateKeyStoreUrl' property to point the driver to the trusted root certificate keystore.
2) Generate the client private key and certificate or use keys and certificate files generated by the MySQL server. Convert the client key and certificate files to a PKCS #12 archive and import the archive into a Java keystore. Use 'clientCertificateKeyStoreUrl' property to point the driver to the client certificate keystore.
3) Use 'clientCertificateKeyStorePassword' and 'trustCertificateKeyStorePassword' properties to specify passwords for the client and trusted certificates keystores.

See:
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html
https://dev.mysql.com/doc/refman/8.0/en/encrypted-connections.html
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html

Support of the 'Use ANSI quotes to quote identifiers' property
Should not be specified via JDBC URL parameter since it will override the default SQL_MODE system variable, instead of appending 'ANSI_QUOTES' to it's value. Proper implementation has to read default SQL_MODE(which depends on the version of the MySQL Server), append 'ANSI_QUOTES' and update the value using "SET SESSION sql_mode = 'modes';" statement.

Design

Currently the two major MySQL versions supported are 5 and 8. We suggest using MySQL Connector/J 8.0 since it is backward compatible with older versions of MySQL and supports all the new features of recent releases.

The suggestion is to move database-plugins module from hydrator-plugins repository to database-plugins repo in data-integrations organization as described in Plugins Repo Split. There is existing code in database-plugins that may be reused for MySQL plugin. We suggest creating a multi-module Maven project where existing `database-plugins` will be a common functionality module for all subsequent DB plugins and each plugin for a specific database (in this case MySQL) will depend on it. Having each DB plugin in a dedicated module allows us to create separately deliverable artifacts, so user can upload only those plugins they need.

Sink Properties

User Facing NameTypeDescriptionConstraints
LabelStringLabel for UI
Reference NameStringUniquely identified name for lineage
HostStringMysql hostRequired (defaults to localhost on UI)
PortNumberSpecific port where mysql running on

Optional

(default 3306)

DatabaseStringDatabase name to connectRequired
UsernameStringDB usernameRequired
PasswordPasswordUser passwordRequired
Transaction Isolation LevelSelectTransaction isolation level for queries run by this sink
Connection ArgumentsKeyvalue

A list of arbitrary string tag/value pairs as connection arguments, list of properties

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html


Table NameStringName of a database table to write to
Use SSLSelectTurns on SSL encryption. The connection will fail if SSL is not available.
Keystore URLStringURL to the client certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Keystore password

StringPassword for the client certificates KeyStore.
Truststore URLStringURL to the trusted root certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Truststore password

StringPassword for the trusted root certificates KeyStore
Use compression protocolBooleanUse zlib compression when communicating with the server. Select this option for WAN connections.
SQL_MODEStringOverride the default SQL_MODE session variable used by the server.

Use ANSI quotes to quote identifiers

BooleanTreats " as an identifier quote character and not as a string quote character.

Source Properties


User Facing NameTypeDescriptionConstraints
LabelStringLabel for UI
Reference NameStringUniquely identified name for lineage
HostStringMysql hostRequired (defaults to localhost on UI)
PortNumberSpecific port where mysql running on

Optional

(default 3306)
DatabaseStringDatabase name to connectRequired
Import QueryStringQuery for import dataValid SQL query
UsernameStringDB usernameRequired
PasswordStringUser passwordRequired
Bounding QueryStringReturns max and minof split-By FiledValid SQL query
Split-By Field NameStringField name which will be used to generate splits
Number of Splits to GenerateNumberNumber of splits to generate
Transaction Isolation LevelSelectTransaction isolation level for queries run by this sink
Connection ArgumentsKeyvalueA list of arbitrary string tag/value pairs as connection arguments, list of properties https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html
Use SSLSelectTurns on SSL encryption. The connection will fail if SSL is not available.
Keystore URLStringURL to the client certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Keystore password

StringPassword for the client certificates KeyStore.
Truststore URLStringURL to the trusted root certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Truststore password

StringPassword for the trusted root certificates KeyStore
Use compression protocolBooleanUse zlib compression when communicating with the server. Select this option for WAN connections.
SQL_MODEStringOverride the default SQL_MODE session variable used by the server.

Use ANSI quotes to quote identifiers

BooleanTreats " as an identifier quote character and not as a string quote character.


Action Properties


User Facing NameTypeDescriptionConstraints
LabelStringLabel for UI
HostStringMysql hostRequired (defaults to localhost on UI)
PortNumberSpecific port where mysql running on

Optional

(default 3306)
DatabaseStringDatabase name to connectRequired
Username

String

DB usernameRequired
PasswordStringUser passwordRequired
Connection ArgumentsKeyvalueA list of arbitrary string tag/value pairs as connection arguments, list of properties https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html
Database CommandStringDatabase command to runValid SQL query
Use SSLSelectTurns on SSL encryption. The connection will fail if SSL is not available.
Keystore URLStringURL to the client certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Keystore password

StringPassword for the client certificates KeyStore.
Truststore URLStringURL to the trusted root certificate KeyStore (if not specified, use defaults). Must be accessible at the same location on host where CDAP Master is running and all hosts on which at least one HDFS, MapReduce, or YARN daemon role is running.

Truststore password

StringPassword for the trusted root certificates KeyStore
Use compression protocolBooleanUse zlib compression when communicating with the server. Select this option for WAN connections.
SQL_MODEStringOverride the default SQL_MODE session variable used by the server.

Use ANSI quotes to quote identifiers

BooleanTreats " as an identifier quote character and not as a string quote character.



Approach

Create a module mysql-plugin in database-plugins project, reuse existing database-plugins code if possible. Add MySQL-specific properties to configuration, add support for MySQL-specific datatypes. Update UI widgets JSON definitions.

...