java.sql.SQLException: Network error IOException: Connection timed out: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.zqy.consume.util.JdbcUtil.getConnection(JdbcUtil.java:41)
at com.zqy.consume.dao.impl.DailyOutDaoImpl.saveDaily(DailyOutDaoImpl.java:81)
at com.zqy.consume.po.Test.main(Test.java:23)
Caused by: java.net.ConnectException: Connection timed out: 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:519)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:289)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:297)这是DriverManager.getConnection(url,user,pwd)报的错误
driver = net.sourceforge.jtds.jdbc.Driver
url = jdbc:jtds:sqlserver://localhost:1433/consume
user = sa
pwd =123
我在Test里面报这个错误,怎么解决?

解决方案 »

  1.   

    Network error IOException: Connection timed out: connect说明数据库连接超时。检查数据库的服务启动没有。。意思就是连不上数据库。。自己进行一系列的检查云
      

  2.   

    telnet localhost 1433看看有无反应
      

  3.   

    1、服务没开;
    2、用户名密码不对;
    3、consume这个数据库是否存在
      

  4.   

    sqlserver 数据库   ??windows 系统下  我的电脑 鼠标右键  管理   服务   sqlserver 配置管理  sqlserver网络配置 sqlexpress的协议  看一下  tcp/ip  启用了没有