原文:https://blog.csdn.net/qq_39241986/article/details/80848855
这样的错误,你有遇到过吗?
- 1
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNvwVZ2x2bzNXak9CX90TQNNkRrFlQKBTSvwFbslmZvwFMwQzLcVmepNHdu9mZvwFVywUNMZTY18CX052bm9CXycGVPhXUq1UNNpHW4Z0MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2LcRHelR3LcJzLctmch1mclRXY39zN3YTNyUzMwIDOyYDM4EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
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
服务,然后再运行程序,成功,舒服啦 !