抓住今天

抓住今天就抓住了命运!

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  3 随笔 :: 2 文章 :: 9 评论 :: 0 Trackbacks
今天想写个jdbc连接mysql的测试,写好了以后连不上msql,报如下错误:

com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
 at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
 at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2120)
 at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
 at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
 at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
 at java.sql.DriverManager.getConnection(DriverManager.java:525)
 at java.sql.DriverManager.getConnection(DriverManager.java:171)
 at welfare.DBUtil.getMySQLConnection(DBUtil.java:64)
 at welfare.Test.main(Test.java:17)
Caused by: com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
 at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
 at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335)
 at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2043)
 ... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
 at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
 at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
 at java.net.Socket.connect(Socket.java:520)
 at java.net.Socket.connect(Socket.java:470)
 at java.net.Socket.<init>(Socket.java:367)
 at java.net.Socket.<init>(Socket.java:209)
 at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
 at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
 ... 8 more


后来仔细一检查才发现原来是url连接的端口写错了。
posted on 2008-12-12 14:01 jfantasize 阅读(843) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问