JTDS-can't connect to the database, tried all

Help
liatb
2007-11-11
2012-08-15
  • liatb
    liatb
    2007-11-11

    Hi,

    I read all the treads on this issue and I followed the suggestions and still have a problem.

    I made sure the TCP port of sqlserver is 1433 (I ran regedit).

    I ran 'telnet MySQLServer 1433' in command prompt and got:
    Connection to MySQLServer ... Could not open connection to the host, on port 23: Connect failed"


    1. When the url = "jdbc:jtds:sqlserver://localhost:1433"
      then I get the following exception:

    java.sql.SQLException: Network error IOException: Connection refused: connect
    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:507)
    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:585)
    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)


    1. When the url = "jdbc:jtds:sqlserver://localhost:1433;instance=sqlexpress" then I get the followinh exception:

    java.sql.SQLException: Unable to get information from SQL Server: localhost.
    at net.sourceforge.jtds.jdbc.MSSqlServerInfo.<init>(MSSqlServerInfo.java:91)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:263)
    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:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)


    1. When I tried to use the connections from the wizard of jdeveloper, I got the following error:

    Unable to get information from SQL Server: localhost.

    I will very much appreciate any help. I really don't know what else to try..

    Thanks a lot,
    Liat

     
    • Steve Ash
      Steve Ash
      2007-11-11

      If you have downloaded SQL 2005 Express, you need to run the MSSQL Surface Area Reduction tool (its called something like that, Im not positive). By default when you install SQL Server 2005, it does not enable the TCP/IP interface to the engine for security reasons. You must use this tool to explicitly enable communication over TCP/IP. Besides that then, you just have to check your connection.url and ensure you don't have firewall software blocking requests. It's going to be something incredibly simple- becuase certainly this is the most common operation to perform with jTDS

      Steve

       
    • liatb
      liatb
      2007-11-12

      Thanks a lot for your reply.

      I already checked and made sure the TCP/IP is enabled.

      I tried it also with instance 'mssql'. I downloaded SQL Server 2000, and I have the tools such as Enterprise Manager and Query Analyzer.

      You can see in example 1 above that when I don't specify any instance I get a different error. It was just me trying to find what is missing in the url so I took this one from one of the threads. I wanted to provide all the information I have in order to provide the full picture of my problem.

      Thanks again for your help,
      Liat

       
    • Steve Ash
      Steve Ash
      2007-11-11

      Also- are you sure the instance is SQLExpress? You explicitly set up your sql server as this instead of the default instance?