原文:https://blog.csdn.net/qq_39241986/article/details/80848855
這樣的錯誤,你有遇到過嗎?
The TCP/IP connection to the host localhost, port 1433 has failed.
- 1
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.".
- 1
- 2
- 3
- 4
- 5
解決方法:
1.選中此電腦–>右鍵管理–>計算機管理–>服務和應用程序
(1)先查看 sql server
服務是否已經開啟
到–>SQL Server 配置管理器–>SQL Server 服務,確保本地Sql Server
服務已經開啟。
(2)再查看 sql server
網絡配置
到–>SQL Server 配置管理器–>SQL Server 網絡配置,確保Named Pipes
和TCP/IP
協議為已啟用狀態。
2.我們再次運行程序,可能會出現還是連接不成功的現象,繼續解決問題:
還是看 sql server
網絡配置
到–>SQL Server 配置管理器–>SQL Server 網絡配置,Named Pipes
和TCP/IP
協議為已啟用狀態,選中TCP/IP
右鍵–>屬性–>IP地址,往下拉滾動條,查看IPALL
中TCP端口
是否為1433,不是,則改為1433
。
最后,重啟SQL Server
服務,然后再運行程序,成功,舒服啦 !