JDBC 连Sql Server 接数据库--The TCP/IP connection to the host localhost, port 1433 has failed

这样的错误,你有遇到过吗?

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.".

解决方法:

1.选中此电脑–>右键管理–>计算机管理–>服务和应用程序
   (1)先查看 sql server 服务是否已经开启
到–>SQL Server 配置管理器–>SQL Server 服务,确保本地Sql Server 服务已经开启。
这里写图片描述
   (2)再查看 sql server 网络配置
到–>SQL Server 配置管理器–>SQL Server 网络配置,确保Named PipesTCP/IP 协议为已启用状态。
这里写图片描述
2.我们再次运行程序,可能会出现还是连接不成功的现象,继续解决问题:
   还是看 sql server 网络配置
到–>SQL Server 配置管理器–>SQL Server 网络配置,Named PipesTCP/IP 协议为已启用状态,选中TCP/IP右键–>属性–>IP地址,往下拉滚动条,查看IPALLTCP端口是否为1433,不是,则改为1433
这里写图片描述
最后,重启SQL Server服务,然后再运行程序,成功,舒服啦 !
这里写图片描述

我用的是:jdk1.7
(对应资源明天放上来)
数据库驱动jar包和jdk1.7下载

  • 8
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

简说Python

多多少少都是爱,感谢充电。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值