我无法通过jdbc打开连接

时间:2011-09-19 12:50:22

标签: android jdbc

我正在尝试通过jdbc打开连接,但我正在

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 127.0.0.1,  port 1433 has failed. 
Error: "Permission denied. Verify the connection properties, check that an instance of SQL    Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is     blocking TCP connections to the port.".

我禁用了avg防火墙,msSqlServer实例已启用,而在tcp / ip属性中,IPALL部分具有tcp端口1433。

这是我尝试这样做的方式

public java.sql.Connection GetConnection() {        
try {
   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
   con = java.sql.DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;Instance=MSSQLSERVER;databaseName=testDBName",
            "testusername", "testPass");
    if (con != null)
        System.out.println("Connection Successful!");
} catch (Exception e) {
    e.printStackTrace();
    System.out.println("Error Trace in getConnection() : "
            + e.getMessage());
}
return con;
}

我错过了什么?

我将不胜感激。

由于

0 个答案:

没有答案
相关问题