fix #1701 - MySQL 5.7 defaults break database character set check

This commit is contained in:
Xavier Léauté 2015-11-17 15:50:30 -08:00
parent 8fa34ee671
commit ba41f37ce1
1 changed files with 4 additions and 5 deletions

View File

@ -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."
);
}