2016-08-12 64 views
0

這是我的JDBC屬性(使用com.mchange.v2.c3p0.ComboPooledDataSource):春天失敗的JDBC連接遠程MySQL,而本地主機是確定

jdbc.driver=com.mysql.jdbc.Driver 
jdbc.url=jdbc:mysql://myserveraddress:3306/mydatabasename?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false 
jdbc.username=myusername 
jdbc.password=mypassword 

myserveraddresslocalhostmy local ip address,一切都很好:)

然而,當myserveraddressmy server ip address(LAN外部),異常來:(

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out. 
Caused by: java.sql.SQLException: An attempt by a client to checkout a Connection has timed out. 
Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from [email protected] -- timeout at awaitAvailable() 

其實,我已經測試通過CMD服務器地址,HeidiSQL,IntelliJ IDEA的,並且一切正常......

cmd ping and cmd mysql connection is ok

HeidiSQL connection and IntelliJ IDEA mysql connection test is ok

迷惑,感激你的幫忙

回答

0

首先檢查你的端口(3306)是本網頁http://portchecker.co/開放(從外部,路由器可能會阻止你的入站連接端口),如果不是:您糅

- 製作端口轉發之三

OR

-put您的服務器DMZ路由器上

+0

謝謝您的回答,但我不認爲它是服務器端的問題,因爲我可以通過CMD連接到服務器數據庫(MySQL的-u -h -p),並且IDEA也成功測試了mysql連接。 –

相關問題