当前位置: 首页 > 知识库问答 >
问题:

到主机localhost端口1433的TCP/IP连接失败

吴嘉禧
2023-03-14

当我试图通过jdbc将eclipse与sql server连接时,我反复遇到这两个错误。有人能帮我吗?或者解释一下为什么我会得到这个?

1. The TCP/IP connection to the host localhost, port 1433 has failed.  
2. The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.

非常感谢。

String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
Class.forName(driver).newInstance();
String connString      ="jdbc:sqlserver://localhost:1433/databaseName=Engg_Street;instance=SQLSERVER;encrypt=true;     trustServerCertificate=true";
String username = "Vijayalakshmi";
String password = "";
conn = DriverManager.getConnection(connString,username,password);

共有3个答案

欧阳勇军
2023-03-14

对于此类问题 - 可以通过检查所有与 sql Server 相关的服务是否都在运行来解决。

TO check Start -> Run -> services.msc 
check services related to sql as
SQL Server (MSSQLSERVER)
SQL Server Agent (MSSQLSERVER)
SQL Server Analysis Services (MSSQLSERVER)
SQL Server Browser
SQL Server Integration Services 10.0
SQL Server Reporting Services (MSSQLSERVER)
SQL Server VSS Writer

启动所有上述服务。并将启动类型设置为自动。

SQL Active Directory 帮助程序服务不需要保持运行。

它可用于处理错误 SQL Server 连接错误 2,并且通过 TCP/IP 连接到主机本地主机,端口 1433 已失败。错误:“连接被拒绝:

澹台臻
2023-03-14

如果您正在运行SQLSERVER EXPRESS:

使用“SQL Server配置管理器”或在Win R上写入“mmc.exe ”,然后搜索“SQL Server网络配置”,在“SQLEXPRESS协议”中启用TCP/IP选项

我希望这对某些人有用!!

杨晟
2023-03-14
You need to Go to Start > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager

当它打开时转到

SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for SQLExpress 

在哪里可以找到协议 TCP/IP,如果禁用,则启用它 单击 TCP/IP,您将找到其属性。

在此属性中,删除所有TCP动态端口并将值1433添加到所有TCP端口,然后重新启动SQL Server服务

它完成了。。。

 类似资料: