Accessing the H2 Console

By default, the console view of the H2 database is disabled. Before accessing the H2 database, we must enable it by using the following property:

spring.h2.console.enabled=true

Once we have enabled the H2 console, now we can access the H2 console in the browser by invoking the URL http://localhost:8082/h2-console

Note: Provide your port number in which your spring application is running

The following figure shows the console view of the H2 database.

Spring Boot with H2 Database

H2 Database in Spring Boot is an embedded, open-source, and in-memory database. It is a relational database management system written in Java. It is a client/server application. It stores data in memory, not persist the data on disk. Here we will be discussing how can we configure and perform some basic operations in Spring Boot using H2 Database.

In this article, we will explore the benefits and usage of H2 database in Spring Boot applications. Key features such as ease of setup, configuration, and running SQL queries will be covered.

What is H2 Database?

H2 is a lightweight and fast SQL database written in Java. It can run in two modes: in-memory and embedded. The in-memory mode is particularly useful for testing and development because it allows you to create a temporary database that is automatically destroyed when the application stops. The embedded mode is used for applications that need a small, self-contained database.

Features of the H2 Database:

  • Very fast, open-source, JDBC API
  • Embedded and server modes; disk-based or in-memory databases.
  • Transaction support, multi-version concurrency
  • Browser-based Console application
  • Encrypted databases
  • Fulltext search
  • Pure Java with a small footprint: around 2.5 MB jar file size
  • ODBC driver

Similar Reads

Configure H2 Database in Spring Boot Application

Below are the steps to set up H2 database in Spring Boot application....

Accessing the H2 Console

By default, the console view of the H2 database is disabled. Before accessing the H2 database, we must enable it by using the following property:...

Using H2 Database to perform CRUD Operation in Spring Boot

We are going to perform some basic CRUD Operations by creating a Spring Boot Application and using the H2 Database....

Accessing H2 Database

Below are the properties for the application.properties file....

Conclusion

In this article, we have learned how to configure, access H2 Database and how to test endpoints in Postman for managing the running database....