Home  >  Article  >  Database  >  How to Resolve \"Server Time Zone Value Central European Time\" Error in MySQL Connector?

How to Resolve \"Server Time Zone Value Central European Time\" Error in MySQL Connector?

Linda Hamilton
Linda HamiltonOriginal
2024-10-23 14:47:52769browse

How to Resolve

MySQL Connector Error: "Server Time Zone Value Central European Time"

Question:

When attempting to connect to a MySQL database using the MySQL connector, an error occurs stating that the server time zone value "Central European Time" is unrecognized or ambiguous.

Project Context:

This issue arises in a small web project utilizing JavaEE, Tomcat 8.5, MySQL, and Maven.

Attempted Solutions:

  • Downgrading the MySQL connector version from 6.x to 5.1.39
  • Modifying the database connection URL in context.xml

Original Connection URL:

<code class="xml">URL="jdbc: mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode=false;serverTimezone=CEST;useSSL=false;</code>

Error Message:

Caused by:
  com.mysql.cj.core.exceptions.InvalidConnectionAttributeException:  The server time zone value 'Mitteleurop?ische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

Solution:

The solution involves modifying the database connection URL in context.xml to include the correct time zone value and encoding:

<code class="xml">url="jdbc:mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode=false&amp;serverTimezone=Europe/Amsterdam&amp;useSSL=false"</code>

Note:

  • Replace "Europe/Amsterdam" with the appropriate time zone for your location.
  • "&" encoding is required to escape the ampersand character in the URL string.

The above is the detailed content of How to Resolve \"Server Time Zone Value Central European Time\" Error in MySQL Connector?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn