How do you view contents of play 2.7 H2 database using h2-browser?

偶尔善良 提交于 2021-01-29 04:08:21

问题


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:

  1. Close the program and close the database connection (if the program is not closed, an error will be reported and cannot be changed)
  2. Delete the database and delete the xml file in dataSources under .idea
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!