700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > springboot使用jdbc连接mysql数据库时测试连接错误

springboot使用jdbc连接mysql数据库时测试连接错误

时间:2022-09-19 17:03:16

相关推荐

springboot使用jdbc连接mysql数据库时测试连接错误

在使用yml文件配置mysql数据库的连接信息时,出现以下的错误

出现这种问题的原因是由于版本问题:

显示新版本的数据库连接程序需要指定UTC时区,改正方法将配置文件中的“url”后面加上指定的时区

这里给出propertie问件和yml文件配置的修改:

原properties文件配置:

jdbc.driverClass = com.mysql.jdbc.Driverjdbc.url = jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8jdbc.username = rootjdbc.password = 123456

更改后properties文件配置

jdbc.driverClass = com.mysql.jdbc.Driverjdbc.url = jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMTjdbc.username = rootjdbc.password = 123456

如果使用yml文件配置:

原yml文件配置:

spring:datasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8driver-class-name: com.mysql.jdbc.Driver

修改后的yml配置文件:

spring:datasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMTdriver-class-name: com.mysql.jdbc.Driver

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。