如何使用h2-浏览器查看play 2.7 H2数据库的内容? [英] How do you view contents of play 2.7 H2 database using h2-browser?

查看:155
本文介绍了如何使用h2-浏览器查看play 2.7 H2数据库的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Play 2.7中查看嵌入式H2数据库的内容?

How do you view the contents of an embedded H2 database, in Play 2.7?

先前的研究:
看来步骤应该是运行 sbt shell .然后运行 h2-browser sbt run ,以便它们处于同一进程中?如果使用平滑,则调用端点以触发编译/数据库创建.
使用

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=""

我已连接,但无法进行身份验证.尝试了多种usr/password组合.

I connects, but cannot authenticate. Multiple usr/password combinations tried.

错误的用户名或密码[28000-199] 28000/28000

Wrong user name or password [28000-199] 28000/28000

scala:2.13
play-slick:4.0.2
h2:1.4.199

Scala:2.13
play-slick:4.0.2
h2:1.4.199

推荐答案

原因:

首次连接到H2数据库时,H2数据库会初始化用户名和密码,但是在配置文件中定义了数据库用户名和密码的属性,从而导致冲突.

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.

解决方案:

  1. 关闭程序并关闭数据库连接(如果未关闭程序,将报告错误并且无法更改)
  2. 删除数据库并在.idea下删除dataSources中的xml文件
  3. 重新创建数据库并启动项目

这篇关于如何使用h2-浏览器查看play 2.7 H2数据库的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆