Accessing memory database in Play!
The other day I was running some unit tests in an app using the Play! framework and I wanted to see how the data in the database looked like. Tests are run using a H2 memory database so accessing this was not as straightforward as I am used to since most configuration in Play! is done by convention (or magic, not sure which). So I did not know the connection string to the database nor the credentials used by the framework. After some googling I came across the information needed.
First start your test and when you are at a breakpoint open the database browser supplied by Play! at localhost:9000/@db (this was new to me as well). Select the Generic Server option and use these parameters.
Parameter | Value |
---|---|
JDBC URL | jdbc:h2:mem:play |
User Name | sa |
Password | <none> |
You should now be able to access the database used by your tests.