Package io.debezium.connector.mysql
Class MySqlConnection
java.lang.Object
io.debezium.jdbc.JdbcConnection
io.debezium.connector.mysql.MySqlConnection
- All Implemented Interfaces:
AutoCloseable
JdbcConnection extension to be used with MySQL Server- Author:
- Jiri Pechanec, Randall Hauch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classHelper to gain access to protected methodstatic classstatic classNested classes/interfaces inherited from class io.debezium.jdbc.JdbcConnection
JdbcConnection.BlockingMultiResultSetConsumer, JdbcConnection.BlockingResultSetConsumer, JdbcConnection.CallPreparer, JdbcConnection.ConnectionFactory, JdbcConnection.MultiResultSetConsumer, JdbcConnection.Operations, JdbcConnection.ParameterResultSetConsumer, JdbcConnection.ResultSetConsumer, JdbcConnection.ResultSetExtractor<T extends Object>, JdbcConnection.ResultSetMapper<T extends Object>, JdbcConnection.StatementFactory, JdbcConnection.StatementPreparer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MySqlConnection.MySqlConnectionConfigurationprivate static org.slf4j.Loggerprivate final MySqlFieldReaderprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprotected static final String -
Constructor Summary
ConstructorsConstructorDescriptionMySqlConnection(MySqlConnection.MySqlConnectionConfiguration connectionConfig) Creates a new connection using the supplied configuration.MySqlConnection(MySqlConnection.MySqlConnectionConfiguration connectionConfig, MySqlFieldReader fieldReader) Creates a new connection using the supplied configuration. -
Method Summary
Modifier and TypeMethodDescriptionQuery the database server to get the list of the binlog files availble.voidclose()Determine the earliest binlog filename that is still available in the server.getColumnValue(ResultSet rs, int columnIndex, Column column, Table table) getEstimatedTableSize(TableId tableId) static StringgetJavaEncodingForMysqlCharSet(String mysqlCharsetName) protected StringRead the Ssl Version session variable.protected booleanDetermine whether the MySQL server has the row-level binlog enabled.protected booleanDetermine whether the MySQL server has the binlog_row_image set to 'FULL'.booleanDetermine whether the MySQL server has GTIDs enabled.booleanDetermine the executed GTID set for MySQL.Get the purged GTID values from MySQL (gtid_purged value)querySystemVariables(String statement) quotedTableIdString(TableId tableId) protected Map<String,MySqlConnection.DatabaseLocales> Read the MySQL default character sets for exisiting databases.Read the MySQL charset-related system variables.Read the MySQL system variables.protected StringsetStatementFor(Map<String, String> variables) protected voidsetSystemProperty(String property, Field field, boolean showValueInError) subtractGtidSet(GtidSet set1, GtidSet set2) Determine the difference between two sets.booleanuserHasPrivileges(String grantName) Determine if the current user has the named privilege.Methods inherited from class io.debezium.jdbc.JdbcConnection
buildSelectWithRowLimits, call, commit, config, connect, connection, connection, connectionString, database, execute, execute, executeWithoutCommitting, getAttributeDetails, getColumnsDetails, getCurrentTimestamp, isConnected, isNullable, isTableType, isTableUniqueIndexIncluded, isValid, loadKeyStore, overrideColumn, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTablePreparedStatement, readTableStatement, readTableUniqueIndices, resolveCatalogName, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, singleResultMapper, supportedTableTypes, tableTypes, username
-
Field Details
-
LOGGER
private static org.slf4j.Logger LOGGER -
SQL_SHOW_SYSTEM_VARIABLES
- See Also:
-
SQL_SHOW_SYSTEM_VARIABLES_CHARACTER_SET
- See Also:
-
SQL_SHOW_SESSION_VARIABLE_SSL_VERSION
- See Also:
-
QUOTED_CHARACTER
- See Also:
-
URL_PATTERN
- See Also:
-
originalSystemProperties
-
connectionConfig
-
mysqlFieldReader
-
-
Constructor Details
-
MySqlConnection
public MySqlConnection(MySqlConnection.MySqlConnectionConfiguration connectionConfig, MySqlFieldReader fieldReader) Creates a new connection using the supplied configuration.- Parameters:
connectionConfig-MySqlConnection.MySqlConnectionConfigurationinstance, may not be null.fieldReader- binary or text protocol based readers
-
MySqlConnection
Creates a new connection using the supplied configuration.- Parameters:
connectionConfig-MySqlConnection.MySqlConnectionConfigurationinstance, may not be null.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classJdbcConnection- Throws:
SQLException
-
readMySqlCharsetSystemVariables
Read the MySQL charset-related system variables.- Returns:
- the system variables that are related to server character sets; never null
-
readMySqlSystemVariables
Read the MySQL system variables.- Returns:
- the system variables that are related to server character sets; never null
-
querySystemVariables
-
setStatementFor
-
setSystemProperty
-
getSessionVariableForSslVersion
Read the Ssl Version session variable.- Returns:
- the session variables that are related to sessions ssl version
-
isGtidModeEnabled
public boolean isGtidModeEnabled()Determine whether the MySQL server has GTIDs enabled.- Returns:
falseif the server'sgtid_modeis set and isOFF, ortrueotherwise
-
knownGtidSet
Determine the executed GTID set for MySQL.- Returns:
- the string representation of MySQL's GTID sets; never null but an empty string if the server does not use GTIDs
-
subtractGtidSet
Determine the difference between two sets.- Returns:
- a subtraction of two GTID sets; never null
-
purgedGtidSet
Get the purged GTID values from MySQL (gtid_purged value)- Returns:
- A GTID set; may be empty if not using GTIDs or none have been purged yet
-
userHasPrivileges
Determine if the current user has the named privilege. Note that if the user has the "ALL" privilege this method returnstrue.- Parameters:
grantName- the name of the MySQL privilege; may not be null- Returns:
trueif the user has the named privilege, orfalseotherwise
-
earliestBinlogFilename
Determine the earliest binlog filename that is still available in the server.- Returns:
- the name of the earliest binlog filename, or null if there are none.
-
isBinlogRowImageFull
protected boolean isBinlogRowImageFull()Determine whether the MySQL server has the binlog_row_image set to 'FULL'.- Returns:
trueif the server'sbinlog_row_imageis set toFULL, orfalseotherwise
-
isBinlogFormatRow
protected boolean isBinlogFormatRow()Determine whether the MySQL server has the row-level binlog enabled.- Returns:
trueif the server'sbinlog_formatis set toROW, orfalseotherwise
-
availableBinlogFiles
Query the database server to get the list of the binlog files availble.- Returns:
- list of the binlog files
-
getEstimatedTableSize
-
isTableIdCaseSensitive
public boolean isTableIdCaseSensitive() -
readDatabaseCollations
Read the MySQL default character sets for exisiting databases.- Returns:
- the map of database names with their default character sets; never null
-
connectionConfig
-
connectionString
-
getJavaEncodingForMysqlCharSet
-
getColumnValue
public Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table) throws SQLException - Overrides:
getColumnValuein classJdbcConnection- Throws:
SQLException
-
quotedTableIdString
- Overrides:
quotedTableIdStringin classJdbcConnection
-