Server Time Zone Error: 'AEST' Unrecognized
Problem:
An unrecognized server time zone, 'AEST,' results in an error during Hibernate connection establishment.
Caused by: java.sql.SQLException: The server time zone value 'AEST' is unrecognized or represents more than one time zone.
Copy after login
Solution:
To resolve this error, you need to specify a more specific time zone value using the serverTimezone configuration property for the JDBC connection.
Here's how to do it:
-
Add serverTimezone to Connection String:
In your JDBC connection URL, add the serverTimezone parameter with a specific time zone. For example, if your time zone is "Australia/Sydney," replace "AEST" with "Australia/Sydney" in your code:
jdbc:mysql://localhost:3306/parking_hib?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney;useSSL=false;
Copy after login
-
Disable Legacy Datetime Code:
Ensure that you set useLegacyDatetimeCode to false in the JDBC connection URL, as this might interfere with time zone handling.
-
Update JDBC Connector:
If you're using an outdated version of the JDBC connector, consider updating to the latest version, as it might include bug fixes related to time zone management.
Additional Troubleshooting:
-
Verify Time Zone: Double-check the time zone you're using in the serverTimezone parameter. It should match the time zone of your database server.
-
MySQL Server Configuration: Ensure that the time zone is correctly configured in the MySQL server. You can execute the following command to verify and potentially adjust the time zone:
SET GLOBAL time_zone = 'Australia/Sydney';
Copy after login
-
Library Compatibility: Make sure that the version of the JDBC connector you're using is compatible with the version of MySQL you're connecting to.
Note: If you're still having issues with the time zone, consult the documentation for your specific database or JDBC connector for additional troubleshooting steps.
The above is the detailed content of How to Fix the Hibernate Server Time Zone Error: \'AEST\' Unrecognized?. For more information, please follow other related articles on the PHP Chinese website!