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

时间:2021-11-01 15:22:42

I'm getting this 2 errors repeatedly when I'm trying to connect eclipse with sql server through jdbc. Could anyone help me with this or explain why am I getting this?

当我试图通过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.

Thank you.

谢谢。

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);

2 个解决方案

#1


30  

You need to Go to Start > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager

When it opens Go to

当它打开转到

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

Where you'll find the Protocol TCP/IP, if disabled then Enable it Click on TCP/IP, You'll find its properties.

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

In this properties Remove All the TCP Dynamic Ports and Add value of 1433 to all TCP Port and restart your SQL Server Services > SQL Server

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

And Its Done...

它完成了......

#2


0  

For this kind of issue - you can resolve by checking whether all sql server related services are running or not.

对于此类问题 - 您可以通过检查是否所有与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

Start all the above services. and set to start up type to Automatic.

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

SQL Active Directory Helper Service is not required to keep running.

SQL Active Directory Helper Service不需要继续运行。

It can used to deal with error SQL server connection error 2 and with he TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused:

它可以用来处理错误SQL服务器连接错误2和他与主机localhost的TCP / IP连接,端口1433失败。错误:“连接被拒绝:

#1


30  

You need to Go to Start > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager

When it opens Go to

当它打开转到

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

Where you'll find the Protocol TCP/IP, if disabled then Enable it Click on TCP/IP, You'll find its properties.

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

In this properties Remove All the TCP Dynamic Ports and Add value of 1433 to all TCP Port and restart your SQL Server Services > SQL Server

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

And Its Done...

它完成了......

#2


0  

For this kind of issue - you can resolve by checking whether all sql server related services are running or not.

对于此类问题 - 您可以通过检查是否所有与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

Start all the above services. and set to start up type to Automatic.

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

SQL Active Directory Helper Service is not required to keep running.

SQL Active Directory Helper Service不需要继续运行。

It can used to deal with error SQL server connection error 2 and with he TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused:

它可以用来处理错误SQL服务器连接错误2和他与主机localhost的TCP / IP连接,端口1433失败。错误:“连接被拒绝: