[英]Cannot connect to SQL Server express 2012 from Eclipse and JDBC
我尝试连接到安装在我自己的计算机上的SQL Server Express 2012。 在Ms属性中,SQL名称为: BGHFVUI535V2\\SQLEXPRESS
在Java中,我有:
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
databaseName = "dblfa1;integratedSecurity=true";
String url = "jdbc:sqlserver://BGHFVUI535V2\SQLEXPRESS;user=mysa;password=mypsw;databaseName=dbmy";
Connection con = DriverManager.getConnection(url);
}
catch (Exception e)
{
e.printStackTrace();
}
我得到这个异常:
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host BGHFVUI535V2, 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.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(SQLServerConnection.java:3589)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck(SQLServerConnection.java:1225)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:972)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ClassStart.main(ClassStart.java:34)
在C#中,我具有connectionstring:
string connectionString = "Server=BGHFVUI535V2\\SQLEXPRESS;Database=dbmy;User Id=mysa;Password=mypsw;";
而且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.