到主机的TCP/IP连接,端口1433失败 [英] The TCP/IP connection to the host, port 1433 has failed

查看:257
本文介绍了到主机的TCP/IP连接,端口1433失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JDBC连接的新手,我很困惑.我启用了TCP/IP和命名管道,并且在TCP/IP-> IP地址中,我已将TCP端口设置为1433,并重新启动了服务器.我还可以通过具有高级安全性的Windows防火墙打开对SQL Server的访问权限.问题是我仍然收到此错误:

I am new to JDBC connections and I am very confused. I have enable TCP/IP and Named Pipes and in TCP/IP -> IP Adresses I have set TCP port to 1433 and I have restarted the server. I have also open access to SQL Server via Windows Firewall with Advanced Security. The problem is that I still get this error:

SQLException:与主机MSSQL $ SQLFULL端口的TCP/IP连接 1433失败了.错误:"null.验证连接属性,检查 SQL Server实例正在主机上运行并接受 端口上的TCP/IP连接,并且没有防火墙阻止TCP 连接到端口."

SQLException: The TCP/IP connection to the host MSSQL$SQLFULL, port 1433 has failed. Error: "null. 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."

我在cmd上运行以下命令:telnet SQLFULL 1433并收到以下消息: 无法打开与端口1433上的主机的连接:连接失败

I run on cmd the following: telnet SQLFULL 1433 and I get this message: Could not open connection to the host on port 1433 : connect failed

我的代码:

String url = "jdbc:sqlserver://MSSQL$SQLFULL:1433;databaseName=BA_ELTRUN;";
Connection dbcon = null;
String errorMessages = "";

try
{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(java.lang.ClassNotFoundException e)
{
    System.out.print("ClassNotFoundException: ");
    System.out.println(e.getMessage());
}

try
{
    dbcon = DriverManager.getConnection(url,"username","password");
}
catch(SQLException e)
{
     System.out.print("SQLException: ");
     System.out.println(e.getMessage());
     errorMessages = "Could not close connection with the Database Server: <br>"
                    + e.getMessage();
                    throw new SQLException(errorMessages);
}

任何人都可以帮忙吗?

推荐答案

复制计算机名称

cmd.exe->主机名

cmd.exe -> hostname

右键单击开始",然后单击系统"并复制计算机名称

Right Click on Start then click on System and copy the Computer Name

URL应该是:

 String url = "jdbc:sqlserver://<Computer Name>\\SQLFULL:1433;databaseName=BA_ELTRUN;";

这篇关于到主机的TCP/IP连接,端口1433失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆