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.<init>(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撥通後,項目就可以重啓了!

解決思路:看看數據庫能不能直接打開訪問?不能訪問先解決數據庫問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章