0
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:242)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2369)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:551)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1963)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)

I'm facing this exception after I tried to connect with my driver through the new database profile. The information I have was correct and the TCP port was enabled and the firewall was turned off. I'm using Microsoft SQL server 2008 JDBC driver and I've added the jars.

rjdkolb
  • 10,377
  • 11
  • 69
  • 89
Tai Levi
  • 1
  • 1
  • You can find answers by searching in this site. https://stackoverflow.com/questions/11820799/com-microsoft-sqlserver-jdbc-sqlserverexception-the-tcp-ip-connection-to-the-ho – Supun Amarasinghe Sep 01 '17 at 10:00
  • Please look in to this https://stackoverflow.com/questions/18841744/jdbc-connection-failed-error-tcp-ip-connection-to-host-failed – Zia Sep 01 '17 at 10:15

1 Answers1

0

A "connection refused" is rarely caused by the connecting client, i.e. the JDBC client within your Eclipse setup. A good check is to open a shell (e.g. cmd.exe on Windows) and do a

telnet [server name used in JDBC configuration] 1433

On newer Windows installations you need to install the telnet client because it's not part of the standard installation anymore (Settings -> Software -> Add/Remove Features).

If that leads to a similar error message you can focus your trouble shooting to the network part of your system, since the JDBC side is completely uninvolved. If you can connect, make sure that the server name resolves to the same IP when using the command prompt as it's resolved within Java (I once had this effect which took quite a time to find that out). Especially with localhost as server name one might resolve to 127.0.0.1 while the other resolvs to ::1.

Lothar
  • 5,323
  • 1
  • 11
  • 27