Sql Server Jdbc Error: The Tcp/Ip Connection To The Host Failed

Advertisement

Masukkan script iklan 970x90px

Sql Server Jdbc Error: The Tcp/Ip Connection To The Host Failed

Sabtu, 15 Agustus 2020

I had installed SQL SERVER 2014 Express edition in addition to I was trying to connect to SQL SERVER from Java programme using JDBC, but I was repeatedly getting next error:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connectedness to the host localhost, port 1433 has failed. Error: "connect timed out. Verify the connectedness properties. Make certain that an illustration of SQL Server is running on the host in addition to accepting TCP/IP connections at the port. Make certain that TCP connections to the port are non blocked past times a firewall.".Error spell closing connectedness !!null

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Testing.main(Testing.java:42)

I had checked that illustration of Microsoft SQL SERVER was already running, every bit I was able to connect to it using SQL SERVER Management Studio (SSMS client). I had every bit good checked the JDBC URL, it's right in addition to also, JDBC driver is including inwards CLASSPATH. So what was wrong? Why I was getting this error? in addition to finally, how I managed to ready this error? Read on ....



Cause of fault TCP/IP connectedness to the host Failed

If y'all are getting this fault subsequently installing SQL SERVER 2012 or 2014 spell start fourth dimension trying to connect from Java programme using JDBC, in addition to therefore it's most probable that your SQL SERVER is non soundless configured to head for TCP/IP connectedness on port 1433.

If y'all create got already configured your MSSQL server to head on TCP/IP traffic on port 1433 then it could endure whatever of next 3 reasons:
  • Firewall is blocking the incoming connection
  • SQL SERVER is non running on the host
  • The port y'all create got configured is non correct, i.e. its non 1433

If the SQL SERVER limited is non running in addition to therefore only start your SQL Server, y'all tin practice therefore past times going into Windows Services tab or you tin every bit good start SQL Server from "SQL Server Configuration Manager", every bit shown below:

 Express edition in addition to I was trying to connect to SQL SERVER from Java programme using JDBC SQL Server JDBC Error: The TCP/IP connectedness to the host Failed


By default, when y'all install Microsoft SQL server inwards Windows 8.1, it register itself every bit Windows service in addition to automatically starts when y'all log into Windows. Btw, if y'all are novel into JDBC globe in addition to non done much operate on Java application interfacing database, in addition to therefore y'all should cheque out Core Java, Volume II--Advanced Features, tenth Edition past times Cay S. Horstmann, ane of the best books to larn advanced Java concepts.

 Express edition in addition to I was trying to connect to SQL SERVER from Java programme using JDBC SQL Server JDBC Error: The TCP/IP connectedness to the host Failed



TCP/IP connectedness to the host Failed: Solution

The solution is to ensure that your SQL Server illustration is listening on the port. Follow these steps to ensure that SQL SERVER 2014 is start listening on port 1433:
  1. Go to Start->All Programs-> Microsoft SQL Server 2012-> Configuration Tool
  2. Click SQL Server Configuration Manager
  3. Expand SQL Server Network Configuration-> Protocol
  4. Enable TCP/IP Right box
  5. Double Click on TCP/IP in addition to acquire to IP Addresses Tap in addition to Put port 1433 nether TCP port.

 Express edition in addition to I was trying to connect to SQL SERVER from Java programme using JDBC SQL Server JDBC Error: The TCP/IP connectedness to the host Failed



In Windows 8.1, y'all tin every bit good press Windows + c in addition to click on Search picture to start searching for SQL Server Configuration Manager. Once establish only click on it to open.

Anyway, ane time y'all got to the higher upward shroud only double click on highlighted TCP/IP link in addition to this volition opened upward the next window, brand certain y'all acquire into TCP Port every bit 1433. That's it.

 Express edition in addition to I was trying to connect to SQL SERVER from Java programme using JDBC SQL Server JDBC Error: The TCP/IP connectedness to the host Failed


That's all near how to ready The TCP/IP connectedness to the host localhost, port 1433 has failed error spell connecting to SQL SERVER from Java using JDBC API. You every bit good quest to create user in addition to logins inwards guild to connect using JDBC in addition to type four JDBC driver. I am going to post service that information presently inwards adjacent yoke of articles.


Related Tutorials in addition to Guide
If y'all similar this tutorial in addition to wants to larn to a greater extent than near troubleshooting in addition to debugging unlike fault inwards Java, delight run into next tutorials:
  • How to ready Unsupported major.minor version 52.0 fault inwards Java [solution]
  • Failed to connect to Queue using WebSphere MQ Series fault [solution]
  • java.sql.SQLException: No suitable driver establish for jdbc:jtds:sqlserver [fix]
  • How to fix java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver erorr [solution]
  • Solution of JDBC fault java.lang.ClassNotFoundException: org.postgresql.Drive [solution]
  • How to bargain with java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver? [solution]
  • Root drive of  java.lang.ClassNotFoundException: com.mysql.jdbc.Drive fault inwards Java? [solution]
  • Cause in addition to solution of java.sql.SQLException: No suitable driver : sqljdbc4.jar [solution]
  • Root drive java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inwards Java? [analysis]
  • Step past times Step Guide to connect MySQL database using JDBC API (guide)
  • java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet [fix]
  • Java conduct to connecting Oracle 10g database using JDBC sparse driver (guide)

Further Learning
JSP, Servlets in addition to JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 in addition to 2
Java Platform: Working alongside Databases Using JDBC