【发布时间】:2018-10-06 17:03:52
【问题描述】:
2018-04-19 20:57:38,504 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host MY-PC, port 1433 has failed. Error: "Connection refused: connect. 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.".
我在启动时收到此错误 3 次。我猜这是因为 Grails 在启动时尝试连接数据库三次,基于Burt Beckwith'sNo Fluff Just Stuff's Delayed SessionFactory Creation in Grails
在三个错误提示之后,Grails 在创建 bean(transactionManager、transactionManagerPostProcessor 等)时继续失败。
根据我的理解,这里的问题是创建池。我假设 Hibernate 在 Grails 上处理这个问题。由于数据库仍未在线,因此无法创建池。
为了让您了解问题的背景,Grails 应用程序正在连接到数据库。数据库和 Grails 服务器位于不同的服务器上。两台服务器同时重启。然后 Grails 应用程序在数据库服务器之前首先在线的服务器。这会导致提到的错误,因为 Grails 应用程序尝试连接到尚未在线的数据库。
有没有办法配置 Grails 在创建池时发生错误或异常时重新连接到数据库服务器?我目前使用 MSSQL 作为我的数据库。我希望你能在这方面帮助我。谢谢。
【问题讨论】:
标签: hibernate grails grails-orm datasource