mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-07 03:10:56 +01:00
Moved timezone set statement to connection init sql
Affects issues: - Possibly fixed #1482
This commit is contained in:
parent
fa7827d956
commit
396b51873c
@ -38,7 +38,6 @@ import javax.inject.Singleton;
|
|||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -107,6 +106,7 @@ public class MySQLDB extends SQLDB {
|
|||||||
|
|
||||||
hikariConfig.setUsername(username);
|
hikariConfig.setUsername(username);
|
||||||
hikariConfig.setPassword(password);
|
hikariConfig.setPassword(password);
|
||||||
|
hikariConfig.addDataSourceProperty("connectionInitSql", "set time_zone = '+00:00'");
|
||||||
|
|
||||||
hikariConfig.setPoolName("Plan Connection Pool-" + increment);
|
hikariConfig.setPoolName("Plan Connection Pool-" + increment);
|
||||||
increment();
|
increment();
|
||||||
@ -139,16 +139,9 @@ public class MySQLDB extends SQLDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connection.getAutoCommit()) connection.setAutoCommit(false);
|
if (connection.getAutoCommit()) connection.setAutoCommit(false);
|
||||||
setTimezoneToUTC(connection);
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTimezoneToUTC(Connection connection) throws SQLException {
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
|
||||||
statement.execute("set time_zone = '+00:00'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
super.close();
|
super.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user