Have you ever made such a mistake?
The TCP/IP connection to the host localhost, port 1433 has failed.
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.".
Solutions:
1. Select the computer – & GT; Right click management – & GT; Computer management — & GT; Service and application
(1) first check SQL server
service whether
has been enabled to — > SQL Server configuration Manager — & GT; SQL Server service, make sure local SQL Server
service is enabled.
(2) then check SQL server
network configuration
to — > SQL Server configuration Manager — & GT; SQL Server network configuration ensures that the Named Pipes
and TCP/IP
protocols are enabled.
2. If we run the program again, it may appear that the connection is still unsuccessful, so we can continue to solve the problem:
or code> SQL server network configuration
to — > SQL Server configuration Manager — & GT; SQL Server network configuration, Named Pipes
and TCP/IP
protocol is enabled, select TCP/IP
right click – > Property – & gt; IP address, scroll down to see if IPALL
in TCP port
is 1433, no, then change to 1433
.
finally, restart SQL Server
service, then run the program again, successful, comfortable!