1

I 'm trying to use timezone setting with mariadb connector/J version 3.x. In the documentation,in Timezone consideration, it says:

'a timezone': connector will set connection variable to value. Compare to Auto, this avoids having some additional exchange with server at connection creation, This value MUST correspond to java default timezone.

Can we set a specific timezone for a connection as with the previous setting serverTimeZone or can we only use system timezone? If it is possible to set it can someone provide an example of a connection string, because I tried it and it doesn't work.

3
  • It is enough to set session @time_zone variable with according timeshift value as the most first command in the established connection. You may specify this command in extra connection properties (which allows to specify additional commands executed during the connection establishing) if the connector supports it.
    – Akina
    Commented Nov 1, 2023 at 4:32
  • Docs say "useLegacyDatetimeCode and serverTimezone that control timezone difference. Those options are now removed in 3.x". so use timezone=auto. "connection string, because I tried it and it doesn't work" - example used and what exactly is "doesn't work". What is the functionality you do see.
    – danblack
    Commented Nov 1, 2023 at 4:54
  • I managed to set the timezone using SET timezone inside the db after connecting, but I' m using tomcat and these settings have to be set using the connection string. When I add timezone=value in the connection string it has no effect. For example if I set it to -05:00, the dates (with type DATETIME) are displayed exactly the same as they are stored in the database. When using mysql connector/J instead of mariadb connector they get converted according to the serverTimeZone setting
    – SkyKnight
    Commented Nov 1, 2023 at 19:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.