Re: jdbc syntax for timezone support
Posted by: Filipe Silva
Date: May 04, 2020 12:09PM

Hi Dave,

The hash/pound sign (#) means the beginning of a URL fragment. In Connector/J connection strings this means that whatever comes next is ignored.

So, the correct connection string for you should be:

jdbc:mysql://localhost:3306/mydatabase?serverTimezone=Europe/London&connectTimeout=5&socketTimeout=0&autoReconnect=true

The port reference (3306) is optional and if you don't provide one Connector/J will use 3306 by default (MySQL server's default port). If your server is running on a different port, then you need to identify it. The same is true for the host name. If you don't provide one, Connector/J uses "localhost" by default.

Then, your connection string could be:

jdbc:mysql://localhost/mydatabase?serverTimezone=Europe/London&connectTimeout=5&socketTimeout=0&autoReconnect=true

Or:

jdbc:mysql://:3306/mydatabase?serverTimezone=Europe/London&connectTimeout=5&socketTimeout=0&autoReconnect=true

Or even:

jdbc:mysql:///mydatabase?serverTimezone=Europe/London&connectTimeout=5&socketTimeout=0&autoReconnect=true

In which case both host name and port take the default values.

Mind that this is true for Connector/J 8.0. Connector/5.1 connection string parser may behave differently.

IHTH

Options: ReplyQuote


Subject
Written By
Posted
Re: jdbc syntax for timezone support
May 04, 2020 12:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.