问题描述:
使用JdbcTemplate连接数据库时出现java.sql.SQLException异常:
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 specific time zone value if you want to utilize time zone support.
原因分析:
jdbc驱动新特性:连接数据库的"url"需指定UTC时区
原代码:
解决方案:
在"url"属性值后添加:
?useCharactorEncoding=utf-8&useSSL=false&serverTimezone=UTC
修改后代码:
jdbc:mysql://localhost:3306/spring_db?useCharactorEncoding=utf-8&useSSL=false&serverTimezone=UTC