@Override
    public void check(final DataSource dataSource) {
        try (
                Connection connection = dataSource.getConnection();
                PreparedStatement preparedStatement = connection.prepareStatement(SHOW_VARIABLES_SQL)) {
            int parameterIndex = 1;
            for (Entry<String, String> entry : REQUIRED_VARIABLES.entrySet()) {
                preparedStatement.setString(parameterIndex++, entry.getKey());
            }
            try (ResultSet resultSet = preparedStatement.executeQuery()) {
                while (resultSet.next()) {
                    String variableName = resultSet.getString(1).toUpperCase();
                    String expectedValue = REQUIRED_VARIABLES.get(variableName);
                    String actualValue = resultSet.getString(2);
                    ShardingSpherePreconditions.checkState(expectedValue.equalsIgnoreCase(actualValue), () -> new UnexpectedVariableValueException(variableName, expectedValue, actualValue));
                }
            }
        } catch (final SQLException ex) {
            throw new CheckDatabaseEnvironmentFailedException(ex);
        }
    }
@Test
    void assertCheckFailure() throws SQLException {
        when(preparedStatement.executeQuery()).thenReturn(resultSet);
        when(resultSet.next()).thenThrow(new SQLException(""));
        assertThrows(CheckDatabaseEnvironmentFailedException.class, () -> variableChecker.check(dataSource));
    }