English 中文(简体)
何时出现这一例外? [闭门]
原标题:when this exception occurs? [closed]
  • 时间:2011-06-11 06:20:28
  •  标签:
  • java
  • jdbc
com.mysql.jdbc.CommunicationsException: Communications link failure due to und
lying exception:

** BEGIN NESTED EXCEPTION **

java.net.ConnectException
MESSAGE: Connection timed out: connect

STACKTRACE:

java.net.ConnectException: Connection timed out: 

connect
        at java.net.DualStackPlainSocketImpl.connect0

(Native Method)
        at 

java.net.DualStackPlainSocketImpl.socketConnect

(DualStackPlainSocke
mpl.java:69)
        at java.net.AbstractPlainSocketImpl.doConnect

(AbstractPlainSocketImpl.
va:316)
        at 

java.net.AbstractPlainSocketImpl.connectToAddress

(AbstractPlainSock
Impl.java:177)
        at java.net.AbstractPlainSocketImpl.connect

(AbstractPlainSocketImpl.ja
:164)
        at java.net.PlainSocketImpl.connect

(PlainSocketImpl.java:154)
        at java.net.SocksSocketImpl.connect

(SocksSocketImpl.java:390)
        at java.net.Socket.connect(Socket.java:578)
        at java.net.Socket.connect(Socket.java:527)
        at java.net.Socket.<init>(Socket.java:424)
        at java.net.Socket.<init>(Socket.java:240)
        at 

com.mysql.jdbc.StandardSocketFactory.connect

(StandardSocketFactory.
va:173)
        at com.mysql.jdbc.MysqlIO.<init>

(MysqlIO.java:268)
        at com.mysql.jdbc.Connection.createNewIO

(Connection.java:2745)
        at com.mysql.jdbc.Connection.<init>

(Connection.java:1553)
        at com.mysql.jdbc.NonRegisteringDriver.connect

(NonRegisteringDriver.ja
:285)
        at java.sql.DriverManager.getConnection

(DriverManager.java:620)
        at java.sql.DriverManager.getConnection

(DriverManager.java:200)
        at Database.Connectivity.<init>

(Connectivity.java:48)
        at Form.SignIn.<init>(SignIn.java:64)
        at Form.SignIn$5.run(SignIn.java:389)
        at java.awt.event.InvocationEvent.dispatch

(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEvent

(EventQueue.java:649)
        at 

java.awt.EventDispatchThread.pumpOneEventForFilters

(EventDispatchTh
ad.java:255)
        at 

java.awt.EventDispatchThread.pumpEventsForFilter

(EventDispatchThrea
java:170)
        at 

java.awt.EventDispatchThread.pumpEventsForHierarchy

(EventDispatchTh
ad.java:160)
        at java.awt.EventDispatchThread.pumpEvents

(EventDispatchThread.java:15

        at java.awt.EventDispatchThread.pumpEvents

(EventDispatchThread.java:14

        at java.awt.EventDispatchThread.run

(EventDispatchThread.java:136)


** END NESTED EXCEPTION **



Last packet sent to the server was 0 ms ago.
        at com.mysql.jdbc.Connection.createNewIO

(Connection.java:2820)
        at com.mysql.jdbc.Connection.<init>

(Connection.java:1553)
        at com.mysql.jdbc.NonRegisteringDriver.connect

(NonRegisteringDriver.ja
:285)
        at java.sql.DriverManager.getConnection

(DriverManager.java:620)
        at java.sql.DriverManager.getConnection

(DriverManager.java:200)
        at Database.Connectivity.<init>

(Connectivity.java:48)
        at Form.SignIn.<init>(SignIn.java:64)
        at Form.SignIn$5.run(SignIn.java:389)
        at java.awt.event.InvocationEvent.dispatch

(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEvent

(EventQueue.java:649)
        at 

java.awt.EventDispatchThread.pumpOneEventForFilters

(EventDispatchTh
ad.java:255)
        at 

java.awt.EventDispatchThread.pumpEventsForFilter

(    EventDispatchThrea
java:170)
        at 

java.awt.EventDispatchThread.pumpEventsForHierarchy

(EventDispatchTh
ad.java:160)
        at java.awt.EventDispatchThread.pumpEvents

(EventDispatchThread.java:15

        at java.awt.EventDispatchThread.pumpEvents

(EventDispatchThread.java:14

        at java.awt.EventDispatchThread.run

(EventDispatchThread.java:136)
问题回答

如果发生这种情况,

  • MySQL server is too busy or hung
  • Network unreachable
  • MySQL server is not started
  • connection parameters used are not valid. (host/port)

Check if you can telnet to the host port of mysql server from the server/machine you are executing this code. If the host and port are valid and the connection is fine, then telnet will show a blank screen. Otherwise it would show something like

连接当地东道方...... 不能在3306号港口与东道国建立联系: 连接失败

如果:

  • the MySQL service is catatonic / hung,
  • the MySQL service is running but is too busy to accept new connections,
  • a firewall is "black holing" connection attempts, or
  • a networking hardware or routing problem is "black holing" connection attempts.

缺乏联系还有其他原因,但会造成不同的例外或不同的信息。 (例如,你可以看到“互联拒绝”、“不知名东道方”、“不可接受”、“网络不可接受”......)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签