def METHOD_NAME(cls, connection):
    if connection.state == 'open':
        logger.debug('Connection is already open, skipping open.')
        return connection
    credentials = cls.get_credentials(connection.credentials)
    kwargs = {"host": credentials.host, "username": credentials.username, "password": credentials.password,
              "database": credentials.schema}
    if credentials.port:
        kwargs["port"] = credentials.port
    try:
        connection.handle = mysql.connector.connect(**kwargs)
        connection.state = 'open'
    except mysql.connector.Error:
        try:
            logger.debug("Failed connection without supplying the `database`. "
                         "Trying again with `database` included.")
            # Try again with the database included
            kwargs["database"] = "information_schema"
            connection.handle = mysql.connector.connect(**kwargs)
            connection.state = 'open'
        except mysql.connector.Error as e:
            logger.debug("Got an error when attempting to open a StarRocks "
                         "connection: '{}'".format(e))
            connection.handle = None
            connection.state = 'fail'
            raise dbt.exceptions.FailedToConnectError(str(e))
    if credentials.version is None:
        cursor = connection.handle.cursor()
        try:
            cursor.execute("select current_version()")
            connection.handle.server_version = _parse_version(cursor.fetchone()[0])
        except Exception as e:
            logger.debug("Got an error when obtain StarRocks version exception: '{}'".format(e))
    else:
        version = credentials.version.strip().split('.')
        if len(version) == 3:
            connection.handle.server_version = (int(version[0]), int(version[1]), int(version[2]))
        else:
            logger.debug("Config version '{}' is invalid".format(version))
    return connection