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
Modifier and TypeClassDescriptionprivate static final class
Helper to gain access to protected methodstatic class
Nested 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
Modifier and TypeFieldDescriptionprivate final MySqlConnection.MySqlConnectionConfiguration
private static org.slf4j.Logger
private final MySqlFieldReader
private static final String
private static final String
private static final String
private static final String
protected static final String
-
Constructor Summary
ConstructorDescriptionMySqlConnection
(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.void
close()
Determine the earliest binlog filename that is still available in the server.<T extends DatabaseSchema<TableId>>
ObjectgetColumnValue
(ResultSet rs, int columnIndex, Column column, Table table, T schema) getEstimatedTableSize
(TableId tableId) static String
getJavaEncodingForMysqlCharSet
(String mysqlCharsetName) protected String
Read the Ssl Version session variable.protected boolean
Determine whether the MySQL server has the row-level binlog enabled.protected boolean
Determine whether the MySQL server has the binlog_row_image set to 'FULL'.boolean
Determine whether the MySQL server has GTIDs enabled.boolean
Determine 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,
MySqlJdbcContext.DatabaseLocales> Read the MySQL default character sets for exisiting databases.Read the MySQL charset-related system variables.Read the MySQL system variables.protected String
setStatementFor
(Map<String, String> variables) protected void
setSystemProperty
(String property, Field field, boolean showValueInError) subtractGtidSet
(GtidSet set1, GtidSet set2) Determine the difference between two sets.boolean
userHasPrivileges
(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, 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.MySqlConnectionConfiguration
instance, may not be null.fieldReader
- binary or text protocol based readers
-
MySqlConnection
Creates a new connection using the supplied configuration.- Parameters:
connectionConfig
-MySqlConnection.MySqlConnectionConfiguration
instance, may not be null.
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in 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:
false
if the server'sgtid_mode
is set and isOFF
, ortrue
otherwise
-
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:
true
if the user has the named privilege, orfalse
otherwise
-
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:
true
if the server'sbinlog_row_image
is set toFULL
, orfalse
otherwise
-
isBinlogFormatRow
protected boolean isBinlogFormatRow()Determine whether the MySQL server has the row-level binlog enabled.- Returns:
true
if the server'sbinlog_format
is set toROW
, orfalse
otherwise
-
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 <T extends DatabaseSchema<TableId>> Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table, T schema) throws SQLException - Overrides:
getColumnValue
in classJdbcConnection
- Throws:
SQLException
-
quotedTableIdString
- Overrides:
quotedTableIdString
in classJdbcConnection
-