Class MySqlJdbcContext

  • All Implemented Interfaces:
    AutoCloseable

    public class MySqlJdbcContext
    extends Object
    implements AutoCloseable
    A context for a JDBC connection to MySQL.
    Author:
    Randall Hauch
    • Method Detail

      • logger

        public org.slf4j.Logger logger()
      • username

        public String username()
      • password

        public String password()
      • hostname

        public String hostname()
      • port

        public int port()
      • sslModeEnabled

        public boolean sslModeEnabled()
      • start

        public void start()
      • shutdown

        public void shutdown()
      • 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
      • 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