Moved timezone set statement to connection init sql

Affects issues:
- Possibly fixed #1482
This commit is contained in:
Risto Lahtela 2020-06-07 12:41:37 +03:00
parent fa7827d956
commit 396b51873c

View File

@ -38,7 +38,6 @@ import javax.inject.Singleton;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@ -107,6 +106,7 @@ public class MySQLDB extends SQLDB {
hikariConfig.setUsername(username);
hikariConfig.setPassword(password);
hikariConfig.addDataSourceProperty("connectionInitSql", "set time_zone = '+00:00'");
hikariConfig.setPoolName("Plan Connection Pool-" + increment);
increment();
@ -139,16 +139,9 @@ public class MySQLDB extends SQLDB {
}
}
if (connection.getAutoCommit()) connection.setAutoCommit(false);
setTimezoneToUTC(connection);
return connection;
}
private void setTimezoneToUTC(Connection connection) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("set time_zone = '+00:00'");
}
}
@Override
public void close() {
super.close();