Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.0.5
Description
Given a server that does not run in UTC, the new `timezone` parameter described here https://mariadb.com/kb/en/about-mariadb-connector-j/#jdbc-api-implementation-notes cannot work, even with mysql_tzinfo_to_sql fully and correctly loaded.
In `StandardClient` UTC get's translated into a fixed offset:
if (mustSetTimezone) {
|
if (clientZoneId.getRules().isFixedOffset()) {
|
ZoneOffset zoneOffset = clientZoneId.getRules().getOffset(Instant.now());
|
sessionCommands.add("time_zone='" + zoneOffset.getId() + "'");
|
} else {
|
sessionCommands.add("time_zone='" + conf.timezone() + "'");
|
}
|
}
|
Which is literal `Z` (See `System.out.println(ZoneId.of("UTC").getRules().getOffset(Instant.now()));`}
MariaDB server cannot handle this, resulting in
Exception in thread "main" java.sql.SQLSyntaxErrorException: (conn=2235) Setting configured timezone 'UTC' fail on server.
|
Look at https://mariadb.com/kb/en/mysql_tzinfo_to_sql/ to load tz data on server, or set timezone=disable to disable setting client timezone.
|
at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:280)
|
at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:334)
|
at org.mariadb.jdbc.client.impl.StandardClient.postConnectionQueries(StandardClient.java:369)
|
at org.mariadb.jdbc.client.impl.StandardClient.<init>(StandardClient.java:205)
|
at org.mariadb.jdbc.Driver.connect(Driver.java:70)
|
at org.mariadb.jdbc.Driver.connect(Driver.java:101)
|
at org.mariadb.jdbc.Driver.connect(Driver.java:27)
|
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
|
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
|