问题描述
我是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:
我在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失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!