[英]Hibernate having problems connecting to remote SQL Server
我有一个网页使用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."
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."
这是问题吗? 我该如何解决? 如果不是,那是什么? 随时要求任何其他信息。
好吧,我毕竟设法找到了问题。 它不是\\DB_COMPANY
节,而是端口。 无论出于何种原因,Windows Service都能与该端口进行通信,但该网站却无法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.