com.microsoft.sqlserver.jdbc.SQLSe rverException: The TCP/IP connection to the host  has failed.
I am trying to connect to SQL Server 2005 Express with JDBC. I am getting the following exception: Code SnippetString connectionUrl = "jdbc:sqlserver://localhost:1433;" + "databaseName=IFC3;"; // Declare the JDBC objects. Connection con = null; Statement stmt = null; ResultSet rs = null; try { // Establish the connection. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection(connectionUrl,"ifc2","password"); com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at connectURL.main(connectURL.java:43)I am using the code example that came from Microsoft for making a JDBC connection. I looked at my configuration of SQL Server and change to use a static port 1433. I shut off Windows firewall to make sure it was not blocking communication. When I try to telnet to port 1433 it saysConnecting To 1433...Could not open connection to the host, on port 23: ConnectfailedAny suggestions?Thanks,Tom
May 21st, 2007 6:21pm

Hi,Please enable the 1433 port, if you are using MSSQL 2005 server. By port for TCP/IP is configured to take dynamically, so make it to 1433. Now, how follow the below step.Microsoft SQL Server 2005 --> Configuration Tools --> SQL Server Configuration ManagerPart I (This will connect to your SQL EXPRESS)- Now, under it go to SQL Server 2005 Network Configuration-->Protocols for SQLEXPRESS.- Now, enable the VIA options by double click it.- Then, open TCP/IP part and set TCP Dynamic Ports: 1433 (or something else) under Protocal-->IP Address-->IP AllPart II (This will connect to your MS SQL Server)- Now, under it go to SQL Server 2005 Network Configuration-->Protocols for MSSQLSERVER.- Now, enable the VIA options by double click it.- Then, open TCP/IP part and set TCP Dynamic Ports: 1433 (or something else) under Protocal-->IP Address-->IP AllRegards,PortalAdmin
Free Windows Admin Tool Kit Click here and download it now
September 22nd, 2008 9:57pm

Hi,I have done the below changes Microsoft SQL Server 2005 --> Configuration Tools --> SQL Server Configuration ManagerPart I (This will connect to your SQL EXPRESS)- Now, under it go to SQL Server 2005 Network Configuration-->Protocols for SQLEXPRESS.- Now, enable the VIA options by double click it.- Then, open TCP/IP part and set TCP Dynamic Ports: 1433 (or something else) under Protocal-->IP Address-->IP All Part II (This will connect to your MS SQL Server)- Now, under it go to SQL Server 2005 Network Configuration-->Protocols for MSSQLSERVER.- Now, enable the VIA options by double click it.- Then, open TCP/IP part and set TCP Dynamic Ports: 1433 (or something else) under Protocal-->IP Address-->IP AllBut still i am getting the exception:SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host JENESYS5/SQLEXPRESS, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host JENESYS5/SQLEXPRESS, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1049) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:207) at main.main(main.java:20)BUILD SUCCESSFUL (total time: 16 seconds)Could you please help me to resolve this issue.Thanks and Regards,V.Vithya
April 6th, 2009 7:44am

hi, i am facing the problem The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".so i tried to change my port number in configuration manager..but when i open it fails to open saying you do not premission or server is unreachable.....i thought there was a problem during installation...so i unistalled sql server and installed it again...but the error repeats...can any1 help me rectifying the problem..thanks,anusha
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2009 3:21am

I get exactly the same error: Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host ROLAND/SQLEXPRESS, port 1471 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) ....Strange thing is, I can connect with OSQL.Even stanger, I have a JDBC jndi installed under my app server, than can connect on the port. That is using exaclty the same JDBC driver.But under Hibernate, it gives this error.
June 2nd, 2009 7:12pm

jdbc:sqlserver://localhost\SQLEXPRESS/Databases/EPS:1357;user=epsingall;password=welkom1; Slashes/backslashes like this! Then my error was gone.
Free Windows Admin Tool Kit Click here and download it now
June 2nd, 2009 8:38pm

I was facing same problem. But after changing the configuration as mentioned, it is working for me. The connection URL when the server has a Instance is as follows: try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://127.0.0.1:1433; Instance=SQL2008;" + "databaseName=MB;user=sa;password=123;"; System.out.println("Successful"); Connection con = DriverManager.getConnection(connectionUrl); System.out.println("Successful"); } catch (SQLException e) { System.out.println("SQL Exception: "+ e.toString()); } catch (ClassNotFoundException cE) { System.out.println("Class Not Found Exception: "+ cE.toString()); } Thanks & Regards, M. Rabbi
December 12th, 2010 2:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics