0
如果我這樣做:的Java JDBC:MySQLNonTransientConnectionException試圖與IP地址進行連接時
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/imageusers?autoReconnect=true&useSSL=false&relaxAutoCommit=true", "username", "password");
那麼它完全正常,但如果我這樣做:
Connection myConn = DriverManager.getConnection("jdbc:mysql://IP:3306/imageusers?autoReconnect=true&useSSL=false&relaxAutoCommit=true", "username", "password");
然後,它給了我一個很長錯誤的清單:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
我從這個網站我的IP地址:http://whatismyipaddress.com/ 和雙重檢查它在另一個發現者,這是相同的,所以我不認爲我把IP地址錯誤。我也在Windows防火牆中爲3306端口做了一個例外,並且檢查了MySQL是否在Windows的服務應用程序中運行,並且它是。我已經打開並運行了MySQL程序。我不知道還有什麼要做。
是我使用了ipconfig從命令提示符獲得的私有IP地址,它遵循192.168 ....等。它現在可以工作,但可以通過互聯網訪問嗎?我怎樣才能做到這一點,我可以從另一臺電腦上做到這一點? – hse23
給它一個域名並添加一個DNS條目。 –
@ hse23 https://en.wikipedia.org/wiki/Port_forwarding –