Java - 使用JDBC连接MySql时出现的报错: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
原因:
输入中文字型时会出现以上错误讯息
解决方法:
需要修改文件:application.properties
位置:src/main/resources/application.properties
修改/加入语法:
useUnicode=true&characterEncoding=UTF-8
打开application.properties
# For MySQL Connectionspring.datasource.url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=falsespring.datasource.username=rootspring.datasource.password=rootspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.http.encoding.force=true
修改后:
# For MySQL Connectionspring.datasource.url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=false& useUnicode=true&characterEncoding=UTF-8spring.datasource.username=rootspring.datasource.password=rootspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.http.encoding.force=true