当我尝试通过 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/