Is there a way to avoid recreating the connection pool to an in-memory database when reloading after a code change?
[info] - application - Shutting down connection pool.
[info] - application - Creating Pool for datasource 'default'
[info] - play.api.db.DefaultDBApi - Database [default] connected at jdbc:h2:mem:play
Even if you modify something that's not related to the database, Play shuts down the connection pool and recreates it right after. There must be good reason, and if not, a workaround.
Any help appreciated.
It's normal behavior of the development mode. I can only add that play reload code after request (if the code was changed). All application is reloaded, so connection pulls are recreated as well (and the in-memory database instance if it was created by play):
Running the server in development mode
If you want to persist the data in your in-memory database then you need to run it separately or use it with persistent ability: