连接到MS SQL Server时失败

时间:2018-06-24 14:41:29

标签: java sql-server jdbc

尝试将在同一Win 10计算机上运行的MS SQL服务器与我在Eclipse中的项目连接:

 String url = "jdbc:sqlserver://GOLD\\SQLEXPRESS;databaseName=PrintLog;";
 Connection conn = DriverManager.getConnection(url ,"user","passwd");

但是有例外:

com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host GOLD, named instance sqlexpress failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434.  For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.

计算机名称为GOLD。我可以毫无问题地从C#连接到DB。 Windows和SQL Server均启用身份验证。我希望在连接时获得Windows身份验证

SQL服务器属性: enter image description here

如何查找问题?

UPD

通过添加端口号来连接字符串,我得到了更好的结果:

String url = "jdbc:sqlserver://GOLD\\SQLEXPRESS:1433;databaseName=PrintLog;";

这是否意味着默认端口号不同?

0 个答案:

没有答案