简体   繁体   中英

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. 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:-

@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. You need to change the H2 console's connection string to match that. Click on the disconnect button and it should take you to a connection form. Enter your connection string in the JDBC URL field

Please correct your connection URL in properties file as below:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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