java - 与主机 localhost、端口 1433 的 TCP/IP 连接失败

标签 java sql-server eclipse jdbc

当我尝试通过 jdbc 将 eclipse 与 sql server 连接时,我反复遇到这 2 个错误。谁能帮我解决这个问题或解释我为什么会得到这个?

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

最佳答案

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 

你会在哪里找到协议(protocol) TCP/IP,如果禁用然后启用它点击 TCP/IP,你会找到它的属性。

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

它完成了......

关于java - 与主机 localhost、端口 1433 的 TCP/IP 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18981279/

相关文章:

c# - 使用 SQL 和 C# 检查数字是否在某个范围内

java - 如何在 eclipse : without maven? 的 checkStyle 中使用自定义检查

android - "Unable to start activity , NullPointerException"的原因

java - exec-maven-plugin 错误,即使在工作示例中也是如此

Java try-finally 里面的 try-catch 模式

java - Webdriver 由于超时而阻塞

java - 为 "select ... limit ?,?"准备好的查询检索元数据时出现 MySQLSyntaxErrorException

java - 将 javascript Web 应用程序链接到 java

c# - 可以通过存储过程创建 View 吗?

python - 尝试从外部Python连接到Docker中的SQL Server