Class MySqlConnection

java.lang.Object
io.debezium.jdbc.JdbcConnection
io.debezium.connector.mysql.MySqlConnection
All Implemented Interfaces:
AutoCloseable

public class MySqlConnection extends JdbcConnection
JdbcConnection extension to be used with MySQL Server
Author:
Jiri Pechanec, Randall Hauch
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close() throws SQLException
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class JdbcConnection
      Throws:
      SQLException
    • 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

      protected Map<String,String> readMySqlSystemVariables()
      Read the MySQL system variables.
      Returns:
      the system variables that are related to server character sets; never null
    • querySystemVariables

      private Map<String,String> querySystemVariables(String statement)
    • setStatementFor

      protected String setStatementFor(Map<String,String> variables)
    • setSystemProperty

      protected void setSystemProperty(String property, Field field, boolean showValueInError)
    • getSessionVariableForSslVersion

      protected String 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's gtid_mode is set and is OFF, or true otherwise
    • 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 returns true.
      Parameters:
      grantName - the name of the MySQL privilege; may not be null
      Returns:
      true if the user has the named privilege, or false otherwise
    • earliestBinlogFilename

      public String 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's binlog_row_image is set to FULL, or false otherwise
    • isBinlogFormatRow

      protected boolean isBinlogFormatRow()
      Determine whether the MySQL server has the row-level binlog enabled.
      Returns:
      true if the server's binlog_format is set to ROW, or false otherwise
    • availableBinlogFiles

      public List<String> availableBinlogFiles()
      Query the database server to get the list of the binlog files availble.
      Returns:
      list of the binlog files
    • getEstimatedTableSize

      public OptionalLong getEstimatedTableSize(TableId tableId)
    • isTableIdCaseSensitive

      public boolean isTableIdCaseSensitive()
    • 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
    • connectionConfig

    • connectionString

      public String connectionString()
    • getJavaEncodingForMysqlCharSet

      public static String getJavaEncodingForMysqlCharSet(String mysqlCharsetName)
    • getColumnValue

      public <T extends DatabaseSchema<TableId>> Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table, T schema) throws SQLException
      Overrides:
      getColumnValue in class JdbcConnection
      Throws:
      SQLException
    • quotedTableIdString

      public String quotedTableIdString(TableId tableId)
      Overrides:
      quotedTableIdString in class JdbcConnection