2013-09-24 150 views
15

我反复得到这2个错误,当我试图用日食SQL 服务器通过JDBC连接。任何人都可以帮我解决这个问题,或解释我为什么得到这个?的TCP/IP连接到主机本地主机,端口1433失败

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

错误很明显:JDBC无法使用SSL连接到您的数据库您的数据库是否配置为在端口1433上使用SSL? – Stefan

+0

您正在使用的任何代码?帮助我们提供帮助 – qiGuar

+0

嘿,我已经在我的新问题中发布了代码,你能帮忙吗? –

回答

27
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服务> SQL服务器

及其做...

+0

但在这里,我不能启用SQL Express ..重新启动时错误结束.. –

+0

这是错误“请求失败或服务没有及时响应”.. –

+0

数据库安装错误,eelete注册表,重装它 – sunysen

0

对于本这种问题 - 您可以通过检查是否所有与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失败。错误:“拒绝连接:

相关问题