一、问题
Could not create connection to database server. Attempted reconnect 3 times.
二、问题分析
在Spring-boot项目中使用jdbc连接数据库时报错,依赖的mysql-connector-java版本为8.0.19,url连接为:
jdbc:mysql://localhost:3306/web_video?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true
查阅文档得知是未设置时区,添加:
&serverTimezone=UTC
解决Spring Boot数据库连接超时
本文详细解析了在Spring Boot项目中使用jdbc连接数据库时出现的“Couldnotcreateconnectiontodatabaseserver”错误。通过调整mysql-connector-java依赖版本及正确配置数据库URL中的时区参数,成功解决了数据库连接超时的问题。
5890

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



