Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid opening unused database connections in Play

I have a Play application that defines three different connection configurations in conf/reference.conf. When I run unit tests that require the use of FakeApplication the BoneCP plugin automatically initializes these three connections even when the unit tests do not call any classes that use any database connections. It starts up and shuts down connections for every unit test. This causes unit tests to take forever to complete. Is there a way to lazily start database connections in BoneCP, HikariCP, or some other connection manager, only opening them when they're first used?

I could of course disable BoneCPPlugin altogether inside the relevant unit tests, but what if I have a unit tests that needs one of the connection configurations?

like image 414
Alex Avatar asked Dec 15 '25 12:12

Alex


1 Answers

For HikariCP, just set initializationFailFast=false and minimumIdle=0.

like image 192
brettw Avatar answered Dec 17 '25 02:12

brettw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!