简体   繁体   English

为什么 H2 数据库不在浏览器中显示我的表

[英]Why H2 database doesn't show my table in the browser

I know H2 is an in-memory database and it exists as long as the application is running.我知道 H2 是一个内存数据库,只要应用程序运行它就存在。 I am following this tutorial .我正在关注本教程 It is working fine.它工作正常。 But when I try to check my table in the browser while my app is running.但是当我尝试在我的应用程序运行时在浏览器中检查我的表格时。 But it doesn't show anything there.但它在那里没有显示任何东西。 What is wrong?怎么了? How can I check my table in the browser?如何在浏览器中查看我的表格?

在此处输入图像描述

Updated Info:-更新信息:-

application.properties:-应用程序属性:-

spring.datasource.url=jdbc:h2:file:C:/temp/test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

# Enabling H2 Console
spring.h2.console.enabled=true

# Custom H2 Console URL
spring.h2.console.path=/h2

spring.jpa.hibernate.ddl-auto=none

#Turn Statistics on and log SQL stmts
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.generate_statistics=false
#logging.level.org.hibernate.type=trace
#logging.level.org.hibernate.stat=debug

logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n

Main class:-主class:-

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

The connection string that you're using to connect to your H2 database ( jdbc:h2:~/testdb ) seems to point to a different database from your connection string.您用于连接到 H2 数据库的连接字符串 ( jdbc:h2:~/testdb ) 似乎指向与连接字符串不同的数据库。 You need to change the H2 console's connection string to match that.您需要更改 H2 控制台的连接字符串以匹配它。 Click on the disconnect button and it should take you to a connection form.单击断开连接按钮,它将带您进入连接表单。 Enter your connection string in the JDBC URL field在 JDBC URL 字段中输入您的连接字符串

Please correct your connection URL in properties file as below:请在属性文件中更正您的连接 URL,如下所示:

spring.datasource.url=jdbc:h2:mem:testdb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM