[Spring Boot]运行报错“Error querying database”

本文记录了一次SpringBoot项目中出现的数据库连接错误,并详细展示了错误日志信息。该问题表现为无法获取JDBC连接,通过启动MySQL服务最终解决了这个问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[Spring Boot]运行报错“Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection;”

(之前运行都是好好的,突然运行项目出现问题,报错的是数据库相关,正好顺便整理一下数据库)
具体报错如下:

There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. ### The error may exist in file [C:\Users\(项目路径)\UserMapper.xml] ### The error may involve com.house.mjxd.dao.UserMapper.login ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

显然重点就是没连接上数据库,遂试图检查sqlyog连接数据库,发现连接也出了问题

sqlyog报错2003
解决此问题的方法是启动mysql服务,具体解决过程见这一篇,应该算踩坑集合了吧哈哈哈虽然很简单。

好吧,这篇没什么重要输出,就是说数据库连接问题报的错,解决数据库问题就运行正常了(项目没问题的前提下)

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值