com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

今早启动项目发现报了如下错误:

com.mysql.jdbc.exceptions.jdbc4.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.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
	at com.mysql.jdbc.MysqlIO.(MysqlIO.java:342)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2197)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)

从报错的信息 Communications link failure 来看,言外之意就是访问数据库失败。

于是根据错误提示,就猜测是数据库“坏了”,就先去看看是不是数据库的问题,打开Navicat发现数据库打不开,

于是恍然大悟,原来是自己的VPN没有拨号(我们这数据库开发时出于安全考虑,需要通过VPN才能访问)。

当把VPN拨通后,项目就可以重启了!

解决思路:看看数据库能不能直接打开访问?不能访问先解决数据库问题。

你可能感兴趣的:(Mysql,Java)