Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring Boot – Show H2 Database Content

I have a Spring Boot Application with a H2 database. I can add entries and I can see this entries on the swagger-ui website.

enter image description here

But when I open the H2 console, I can not see the tables or the columns.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Is there a way to show me the content of the database? In a readable format?

My application.properties file:

spring.datasource.url=jdbc:h2:mem:mooddb;
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=a
spring.datasource.password=a
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.sql.init.platform=h2
spring.jpa.hibernate.ddl-auto=create
spring.sql.init.data-locations=classpath:data-h2.sql

spring.h2.console.enabled=true

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

spring.jpa.defer-datasource-initialization=true

spring.h2.console.path=/h2
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false

Thank

>Solution :

The h2 console can be used to execute SQL queries so that you can view the content of the database.

You can execute for example SELECT * FROM YOUR_TABLE; and you will see the result of the query in the console.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading