IDEA工具,java连接数据库查询过程中,出现了以下错误:
java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ 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.
错误原因:需要在连接字符串中明确指定serverTimezone,这样MySQL驱动版本与UTC时区才能配合使用。
解决办法:在你的properties文件中或者DriverConnection(url,user,password)中,Url改为jdbc:mysql://localhost:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC。

以上解决方案来自:
https://blog.csdn.net/correlate/article/details/88719881
个人学习使用
在使用IDEA进行Java开发并尝试连接MySQL数据库时遇到了时区识别错误,错误提示为'Öйú±ê׼ʱ¼ä'未被识别。解决方法是在数据库连接URL中明确指定serverTimezone参数,例如设置为'UTC',修改后的URL为:jdbc:mysql://localhost:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC。这样做可以确保MySQL驱动与UTC时区配合工作。

677

被折叠的 条评论
为什么被折叠?



