[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服务,具体解决过程见这一篇,应该算踩坑集合了吧哈哈哈虽然很简单。

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

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐