【问题标题】:H2 Console can not see tables created by hibernateH2控制台看不到hibernate创建的表
【发布时间】:2019-04-26 12:06:11
【问题描述】:

我有一个使用 JPA 的 JEE Web 项目,应该在 JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) 上运行。我想用内存数据库 H2 测试项目。我部署了我的应用程序,我在控制台上看到以下内容:

13:55:18,587 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: create table seatforshow (id integer not null, isFree boolean not null, price decimal(19,2), rowNo tinyint not null, seatNo tinyint not null, filmShow_id integer not null, primary key (id))

13:55:18,588 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E8171BAB7DF foreign key (cinema_id) references cinema

13:55:18,591 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table filmshow add constraint FKD4A76E81D7BB783F foreign key (film_id) references film

13:55:18,593 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seat add constraint FK35CE0571BAB7DF foreign key (cinema_id) references cinema

13:55:18,595 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: alter table seatforshow add constraint FK5B4E2DA141F8E4BF foreign key (filmShow_id) references filmshow

13:55:18,597 INFO  [stdout] (ServerService Thread Pool -- 87) Hibernate: create sequence hibernate_sequence start with 1 increment by 1

13:55:18,598 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 87) HHH000230: Schema export complete

但是,我打开后

localhost:8080/h2-console/console/

我在那里看不到我的桌子。我想我可能需要提供模式名称(或数据库名称),但我不确定。有人可以帮忙吗?

【问题讨论】:

  • 如果您使用的是内存数据库,那么只要您的应用程序正在运行,您的表将只对您可用。应用程序执行完成后,表将自动从数据库中删除,因此您无法看到任何表
  • 您能说得更具体些吗?我的应用程序仍在服务器上运行,所以我认为表应该仍然可见
  • 尝试访问 localhost:8080/h2-console 并提供为架构提供的检查详细信息,或者发布您的 h2 DB 控制台的屏幕截图
  • @Abhijeet 请看上图
  • 我认为您的表是在不同的架构中创建的,而您正在签入不同的架构

标签: java jpa jboss h2


【解决方案1】:

问题出在上面显示的连接 URL 中: jdbc:h2:~测试 这与定义数据源的文件standalone.xml 中的connectionURL 不匹配。 一旦两者匹配,正确的数据库(以及表)就会显示在控制台上。

【讨论】:

    猜你喜欢
    • 2014-07-29
    • 1970-01-01
    • 2020-01-09
    • 2014-08-15
    • 2019-07-07
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 2019-06-12
    相关资源
    最近更新 更多