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连接到数据库。windows和SQL server都启用了身份验证。我希望在连接时获得Windows身份验证
SQL server属性:
如何找到问题?
UPD公司
我通过在连接字符串中添加端口号得到了更好的结果:
String url = "jdbc:sqlserver://GOLD\\SQLEXPRESS:1433;databaseName=PrintLog;";
这是否意味着默认端口号不同?