From ba41f37ce1a9131a34dcb6cee8a0e1e7098f763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Tue, 17 Nov 2015 15:50:30 -0800 Subject: [PATCH] fix #1701 - MySQL 5.7 defaults break database character set check --- .../io/druid/metadata/storage/mysql/MySQLConnector.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extensions/mysql-metadata-storage/src/main/java/io/druid/metadata/storage/mysql/MySQLConnector.java b/extensions/mysql-metadata-storage/src/main/java/io/druid/metadata/storage/mysql/MySQLConnector.java index d7fa235082d..a0f90c7db6c 100644 --- a/extensions/mysql-metadata-storage/src/main/java/io/druid/metadata/storage/mysql/MySQLConnector.java +++ b/extensions/mysql-metadata-storage/src/main/java/io/druid/metadata/storage/mysql/MySQLConnector.java @@ -30,6 +30,7 @@ import org.apache.commons.dbcp2.BasicDataSource; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.Handle; import org.skife.jdbi.v2.tweak.HandleCallback; +import org.skife.jdbi.v2.util.BooleanMapper; import java.sql.SQLException; @@ -77,16 +78,14 @@ public class MySQLConnector extends SQLMetadataConnector { // ensure database defaults to utf8, otherwise bail boolean isUtf8 = handle - .createQuery("SHOW VARIABLES where variable_name = 'character_set_database' and value = 'utf8'") - .list() - .size() == 1; + .createQuery("SELECT @@character_set_database = 'utf8'") + .map(BooleanMapper.FIRST) + .first(); if (!isUtf8) { throw new ISE( "Database default character set is not UTF-8." + System.lineSeparator() + " Druid requires its MySQL database to be created using UTF-8 as default character set." - + " If you are upgrading from Druid 0.6.x, please make all tables have been converted to utf8 and change the database default." - + " For more information on how to convert and set the default, please refer to section on updating from 0.6.x in the Druid 0.7.1 release notes." ); }