休眠状态,无法连接到远程SQL Server

时间:2019-02-12 17:11:06

标签: sql-server hibernate

我有一个网页,该网页使用Hibernate连接到SQL Server 2017。我已经在服务器既是本地主机又是远程服务器的机器上完成了提到的应用程序的许多安装。

现在,我面临着一种情况,即Hibernate无法稳定与远程服务器的连接(单击“登录”按钮后显示stacktrace页)。我已经检查了所有可能的内容,但找不到错误。这一切都在发生,而我完全能够通过Microsoft SQL Server Management和Windows服务从托管网站的同一台计算机(使用Tomcat)连接到该服务器,同时使用Windows服务,这意味着可以访问远程服务器!

在我看来,问题在于我可以发现此安装与之前的安装之间的唯一区别:到远程服务器的IP链接包含一个额外的参数,即 \ DB_COMPANY ,如下所示(摘自hibernate.cfg):

<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://10.150.10.37\DB_COMPANY:1433;databaseName=COMPANY</property>
<property name="hibernate.connection.username">company</property>
<property name="hibernate.connection.password">Company</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> 

给我的印象是Hibernate无法处理这个额外的参数,并且经过MS SQL Management和提到的服务的测试,\DB_COMPANY补充对于访问远程服务器是必需的。我尝试使用不同的斜杠组合,并且总是出现某种错误。如果使用反斜杠,则表示Error calling Driver#connect;如果是斜杠,则消息The TCP/IP connection to the host 10.150.10.37/DB_COMPANY, port 1433 has failed. Error: "10.150.10.37/DB_COMPANY. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."

这是问题吗?我该如何解决?如果不是,那是什么?随时询问其他信息。

1 个答案:

答案 0 :(得分:0)

好吧,我毕竟设法找到了问题。它不是\DB_COMPANY部分的内容,而是端口。无论Windows Service能够与该端口进行通信的原因为何,网站均无法。