2016-04-18 39 views
0

我在Play Framework 2.3上有一個應用程序,並連接到SQL Server(2008,2012和2014版本)。配置看起來像這樣:如何在Play Framework的配置錯誤後設置autoReconnect?

db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver 
db.default.url="jdbc:sqlserver://192.168.100.101;databaseName=myDatabase;SelectMethod=direct;autoReconnect=true" 

除了在啓動SQL Server之前啓動的應用程序以外,它可以正常工作。在這種情況下發揮產生一個錯誤:

Configuration error[Cannot connect to database [default]] 

是,可能的話,設置PlayFramework全自動重新連接,該錯誤後,當播放到達一個新的請求,我該怎麼辦呢?

回答

1

HikariCP有a property to do exactly what you want

initializationFailFast: This property controls whether the pool will "fail fast" if the pool cannot be seeded with initial connections successfully. If you want your application to start even when the database is down/unavailable, set this property to false. Default: true

您可以使用play-hikaricp module替換默認池(BoneCP),然後配置HikariCP如上所述。

相關問題