1、例如我在SpringBoot项目中使用了阿里的数据库链接池Driud。
有次在启动的时候,会报这样的错:mysql
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure The last packet successfully received from the server was 319 milliseconds ago. The last packet sent successfully to the server was 319 milliseconds ago.
就是数据库链接失败的问题。spring
为何会出现这样的一个问题呢?
出现这样的一个问题,首先肯定是否是数据库问题,看看数据库能不能连上。
若是你的同事或者其余人都可以连上,那么数据库就没有问题。
看看你能不能上网。
若是你能上网,你的网络还OK。sql
若是你使用了代理,就是哪一种能帮助你上谷歌的软件。
你将它关掉,看看问题是否解决了。数据库
#下面这两个配置,能够在每次链接的时候判断一些链接是否有效 spring.datasource.druid.test-on-borrow=true spring.datasource.druid.test-while-idle=true