用正常連接數據庫代碼運行後出現,好像是MySQL訪問地址問題,怎麼解決?
error:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communication link failure, message from server: "Can't get hostname for your address"
鏈接mysql 驅動類 com.mysql.jdbc.Driver 連接字符串
( jdbc:mysql://localhost:3306/pubs ,user=r
oot, password=root} )
(pubs為數據庫名,
localhost為主機地址,若數據庫在遠程則為IP地址
user =用戶名
password = 密碼
)。解決了 就采納喲!