问题
How do you view the contents of an embedded H2 database, in Play 2.7?
Prior research:
It seems the steps should be to run sbt shell
. Then run h2-browser
and sbt run
so they are in the same process? If using slick, then call an endpoint to trigger compilation/database creation.
With a configuration of
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.user=sa
db.default.password=""
I connects, but cannot authenticate. Multiple usr/password combinations tried.
Wrong user name or password [28000-199] 28000/28000
Scala:2.13
play-slick:4.0.2
h2:1.4.199
回答1:
Reason:
When connecting to the H2 database for the first time, the H2 database initializes the user name and password, but properties the database user name and password are defined in the configuration file , causing a conflict.
Solution:
- Close the program and close the database connection (if the program is not closed, an error will be reported and cannot be changed)
- Delete the database and delete the xml file in dataSources under .idea
- Recreate the database and start the project
来源:https://stackoverflow.com/questions/57273009/how-do-you-view-contents-of-play-2-7-h2-database-using-h2-browser