FirebirdSQL / jaybird

JDBC driver for Firebird
https://firebirdsql.org/en/jdbc-driver/
GNU Lesser General Public License v2.1
94 stars 23 forks source link

Timezone warnings #786

Closed ErmacTheSoul closed 8 months ago

ErmacTheSoul commented 8 months ago

using jaybird 4.0.10 and firebird 4.0.4, java 1.0.8_401

getting spammed with warning like this:

8:28:54 PM org.firebirdsql.logging.JulLogger warn WARNING: TimeZone fallback to GMT from +05:00; possible cause: value of sessionTimeZone unknown in Java. Time and Timestamp values may yield unexpected values. Consider setting a different value for sessionTimeZone.

how to fix them?

mrotteveel commented 8 months ago

As mentioned in https://github.com/FirebirdSQL/firebird/issues/8029:

In addition, you can configure your java.util.logging to not log warnings from the logger called org.firebirdsql.gds.impl.GDSHelper. For example by adding to your logging configuration:

org.firebirdsql.gds.impl.GDSHelper.level = OFF

(or with = ERROR, but this is the only thing logged on this logger name, so would effectively be the same)

You can also start your Java application with -Duser.timezone=Asia/Qyzylorda in the arguments to the Java process, or call from within your process:

TimeZone.setDefault(TimeZone.getTimeZone("Asia/Qyzylorda"));

Or you can just consider what warnings are: warnings, not errors, and just leave them be if you can't address them.

mrotteveel commented 8 months ago

I will see if I can reduce the frequency of logging though, maybe doing it for each connection is overkill, or log the rest on DEBUG could be fine as well.

mrotteveel commented 8 months ago

Reducing logging frequency or level scheduled on v6, backport to v5 will be considered as well.

mrotteveel commented 8 months ago

While diving into the code, it looks like part of the problem is that Java expects GMT+05:00, while Firebird expects +05:00, so when I changed things to get the right value to Firebird, it broke the TimeZone selection in GDSHelper, resulting in the logged warning.

Instead of reducing the frequency of logging this, I will detect this situation for offset names, and make it retrieve the right time zone. That leaves the warning available for entirely wrong time zone names.

mrotteveel commented 8 months ago

In addition to the bug fix (which will be backported to Jaybird 5), Jaybird now also automatically converts explicit Java offset names like GMT+05:00 as the session timezone name to +05:00 as expected by Firebird. Previously, we only did this for the default session timezone value derived from the default JVM timezone. This last change will not be backported.

mrotteveel commented 8 months ago

The improvement was not applied for JDBC properties and restored default values.