我需要關於數據庫連接時間錯誤的幫助,我正在使用wamp服務器 我可以訪問PHPMyAdmin拋出此鏈接「192.168.1.88/phpmyadmin」,它工作正常,但我得到一個超時在NetBeans錯誤,我試圖在PC之間的ping,它工作正常連接超時:連接JAVA和Wampserver
這裏是堆棧跟蹤:
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out: connect
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection timed out: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at assurancebensaidv2.jdbcManager.<init>(jdbcManager.java:38)
at assurancebensaidv2.Login.<init>(Login.java:37)
at assurancebensaidv2.Login$8.run(Login.java:761)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
這裏是我的代碼片段:
public class jdbcManager {
public HashMap<String, String> item = new HashMap<>();
public static Connection conn;
private Statement s;
private ResultSet rs;
public jdbcManager() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
javax.swing.JOptionPane.showMessageDialog(null, "Erreur Driver ", "Etat de L'opération", javax.swing.JOptionPane.INFORMATION_MESSAGE);
Logger.getLogger(jdbcManager.class.getName()).log(Level.SEVERE, null, ex);
}
//===================================================================
try {
conn = DriverManager.getConnection("jdbc:mysql://192.168.1.88:3306/agenceassurance", "root", "12345");
} catch (SQLException ex) {
System.out.println(ex.getMessage());
// javax.swing.JOptionPane.showMessageDialog(null, "Erreur Connection Base de donnée", "Etat de L'operation", javax.swing.JOptionPane.INFORMATION_MESSAGE);
}
}}
能請你寫準確,你得到了錯誤的單一數據庫的新用戶帳戶? – Anubhav
嘗試ping此地址'ping 192.168.1.88' –
您是否正在運行與運行WAMPServer的計算機不同的計算機上的java代碼? – RiggsFolly