Grails 2.3.11 ERROR pool.ConnectionPool - 无法创建池的初始连接

时间:2018-04-26 05:33:27

标签: hibernate grails gorm datasource

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.".

我在启动时遇到此错误三次。我想这是因为Grails尝试在启动时根据Burt Beckwith's No Fluff Just Stuff's Delayed SessionFactory Creation in Grails连接数据库三次

在三个错误提示之后,Grails继续在bean创建失败(transactionManager,transactionManagerPostProcessor等)。

根据我的理解,这里的问题是池创建。我假设Hibernate在Grails上处理这个问题。由于数据库仍未联机,因此无法创建池。

为了让您了解问题,Grails应用程序正在连接到数据库。数据库和Grails服务器位于不同的服务器上。两台服务器同时重启。然后Grails应用程序首先在数据库服务器之前联机的服务器。这会导致自Grails应用程序尝试连接到尚未联机的数据库时提到的错误。

有没有办法在创建池时发生错误或异常时将Grails配置为重新连接到数据库服务器?我目前正在使用MSSQL作为我的数据库。我希望你能帮助我。感谢。

1 个答案:

答案 0 :(得分:0)

如果没有备份数据库,您的应用程序将无法有效启动或运行,因此即使您以后可以重新连接,也会错过许多启动事件,例如GORM更新。

由于您的应用程序在数据库启动之前无法工作,您是否可以延迟启动Grails应用程序直到数据库启动后?有多种方法,看起来这样做会给你一个更好更清洁的初始化过程。

相关问题