开发者

I can't open connection via jdbc

开发者 https://www.devze.com 2023-04-05 16:33 出处:网络
I am trying to open a connection via jdbc but I am getting com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 127.0.0.1,port 1433 has failed.

I am trying to open a connection via jdbc but I am getting

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.".

I disabled the avg firewall, the msSqlServer instance is enabled and in tcp/ip properties the IPALL section has as tcp port the 1433.

This is the way I am trying to do this

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", "tes开发者_运维问答tPass");
    if (con != null)
        System.out.println("Connection Successful!");
} catch (Exception e) {
    e.printStackTrace();
    System.out.println("Error Trace in getConnection() : "
            + e.getMessage());
}
return con;
}

What am I missing?

I will appreciate any comment.

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号