ensure ANSI_QUOTES on every MySQL connection

This commit is contained in:
Xavier Léauté 2014-10-31 16:54:20 -07:00
parent 3468163dcd
commit 47eb9c100e
1 changed files with 2 additions and 10 deletions

View File

@ -20,6 +20,7 @@
package io.druid.metadata.storage.mysql; package io.druid.metadata.storage.mysql;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.metamx.common.logger.Logger; import com.metamx.common.logger.Logger;
import com.mysql.jdbc.exceptions.MySQLTransientException; import com.mysql.jdbc.exceptions.MySQLTransientException;
@ -51,18 +52,9 @@ public class MySQLConnector extends SQLMetadataConnector
// so we need to help JDBC find the driver // so we need to help JDBC find the driver
datasource.setDriverClassLoader(getClass().getClassLoader()); datasource.setDriverClassLoader(getClass().getClassLoader());
datasource.setDriverClassName("com.mysql.jdbc.Driver"); datasource.setDriverClassName("com.mysql.jdbc.Driver");
datasource.setConnectionInitSqls(ImmutableList.of("SET sql_mode='ANSI_QUOTES'"));
this.dbi = new DBI(datasource); this.dbi = new DBI(datasource);
dbi.withHandle(new HandleCallback<Void>()
{
@Override
public Void withHandle(Handle handle) throws Exception
{
handle.createStatement("SET sql_mode='ANSI_QUOTES'").execute();
return null;
}
});
} }
@Override @Override