Class MySqlJdbcContext
- java.lang.Object
-
- io.debezium.connector.mysql.legacy.MySqlJdbcContext
-
- All Implemented Interfaces:
AutoCloseable
public class MySqlJdbcContext extends Object implements AutoCloseable
A context for a JDBC connection to MySQL.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMySqlJdbcContext.DatabaseLocales
-
Field Summary
Fields Modifier and Type Field Description protected Configurationconfigprotected static JdbcConnection.ConnectionFactoryFACTORYprotected JdbcConnectionjdbcprotected static StringJDBC_PROPERTY_LEGACY_DATETIMEprotected static org.slf4j.Loggerloggerprotected static StringMYSQL_CONNECTION_URLprivate Map<String,String>originalSystemPropertiesprivate static StringSQL_SHOW_SESSION_VARIABLE_SSL_VERSIONprivate static StringSQL_SHOW_SYSTEM_VARIABLESprivate static StringSQL_SHOW_SYSTEM_VARIABLES_CHARACTER_SET
-
Constructor Summary
Constructors Constructor Description MySqlJdbcContext(MySqlConnectorConfig config)
-
Method Summary
-
-
-
Field Detail
-
MYSQL_CONNECTION_URL
protected static final String MYSQL_CONNECTION_URL
- See Also:
- Constant Field Values
-
JDBC_PROPERTY_LEGACY_DATETIME
protected static final String JDBC_PROPERTY_LEGACY_DATETIME
- See Also:
- Constant Field Values
-
SQL_SHOW_SYSTEM_VARIABLES
private static final String SQL_SHOW_SYSTEM_VARIABLES
- See Also:
- Constant Field Values
-
SQL_SHOW_SYSTEM_VARIABLES_CHARACTER_SET
private static final String SQL_SHOW_SYSTEM_VARIABLES_CHARACTER_SET
- See Also:
- Constant Field Values
-
SQL_SHOW_SESSION_VARIABLE_SSL_VERSION
private static final String SQL_SHOW_SESSION_VARIABLE_SSL_VERSION
- See Also:
- Constant Field Values
-
FACTORY
protected static JdbcConnection.ConnectionFactory FACTORY
-
logger
protected static final org.slf4j.Logger logger
-
config
protected final Configuration config
-
jdbc
protected final JdbcConnection jdbc
-
-
Constructor Detail
-
MySqlJdbcContext
public MySqlJdbcContext(MySqlConnectorConfig config)
-
-
Method Detail
-
config
public Configuration config()
-
jdbc
public JdbcConnection jdbc()
-
logger
public org.slf4j.Logger logger()
-
username
public String username()
-
password
public String password()
-
hostname
public String hostname()
-
port
public int port()
-
sslMode
public MySqlConnectorConfig.SecureConnectionMode sslMode()
-
sslModeEnabled
public boolean sslModeEnabled()
-
sslKeyStore
public String sslKeyStore()
-
sslKeyStorePassword
public char[] sslKeyStorePassword()
-
sslTrustStore
public String sslTrustStore()
-
sslTrustStorePassword
public char[] sslTrustStorePassword()
-
eventProcessingFailureHandlingMode
public CommonConnectorConfig.EventProcessingFailureHandlingMode eventProcessingFailureHandlingMode()
-
inconsistentSchemaHandlingMode
public CommonConnectorConfig.EventProcessingFailureHandlingMode inconsistentSchemaHandlingMode()
-
shutdown
public void shutdown()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
isGtidModeEnabled
public boolean isGtidModeEnabled()
Determine whether the MySQL server has GTIDs enabled.- Returns:
falseif the server'sgtid_modeis set and isOFF, ortrueotherwise
-
knownGtidSet
public String 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
public GtidSet subtractGtidSet(GtidSet set1, GtidSet set2)
Determine the difference between two sets.- Returns:
- a subtraction of two GTID sets; never null
-
purgedGtidSet
public GtidSet 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
public boolean userHasPrivileges(String grantName)
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
-
connectionString
public String connectionString()
-
readMySqlCharsetSystemVariables
protected Map<String,String> readMySqlCharsetSystemVariables()
Read the MySQL charset-related system variables.- Returns:
- the system variables that are related to server character sets; never null
-
readMySqlSystemVariables
public Map<String,String> readMySqlSystemVariables()
Read the MySQL system variables.- Returns:
- the system variables that are related to server character sets; never null
-
readDatabaseCollations
protected Map<String,MySqlJdbcContext.DatabaseLocales> readDatabaseCollations()
Read the MySQL default character sets for exisiting databases.- Returns:
- the map of database names with their default character sets; never null
-
setSystemProperty
protected void setSystemProperty(String property, Field field, boolean showValueInError)
-
getSessionVariableForSslVersion
public String getSessionVariableForSslVersion()
Read the Ssl Version session variable.- Returns:
- the session variables that are related to sessions ssl version
-
-