Can't Connect with SQL Server 2008

Mei Ling
2009-08-06
2012-08-15
  • Mei Ling

    Mei Ling - 2009-08-06

    Hi All,
    I'm using jtds v1.22 to connect my tomcat5.5 and SQL Server 2008. But cannot connect and show a lot of error!

    my connection string as below:
    db.connection.driver_class=net.sourceforge.jtds.jdbc.Driver
    db.connection.url=jdbc:jtds:sqlserver://localhost:1433/myDb;
    db.connection.username=sa
    db.connection.password=password

    The error as below:-
    java.sql.SQLException: Network error IOException: Connection refused: connect
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:385)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:182)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
    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:519)
    at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:304)
    at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:255)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:310)
    ... 10 more

    Appreciate if you can help me...

    Thank you...

     
    • momo

      momo - 2009-08-08

      Hi,

      don't know what exactly the problem is, but the error message indicates that either no one is listening on the specified address/socket or that a firewall is blocking the request. Make sure TCP/IP connections are enabled in your server and bound to port 1433 of the local network interface and that no firewall is blocking the request (e.g. the Windows Vista firewall blocks such connections by default).

      Hope that helps,
      momo

       
      • Brian Clark

        Brian Clark - 2009-08-09

        Remember, the Windows 2008 firewall is on by default, and it blocks SQL port 1433 by default as well.

         

Log in to post a comment.