DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Spring Config Integration With a PCF Application: A Step-by-Step Guide
  • Integrate Spring With Open AI
  • Enterprise RIA With Spring 3, Flex 4 and GraniteDS

Trending

  • 9 Practical Ways to Fix Laravel Performance Issues in Production
  • MCP Is Coming to Your Desktop Applications
  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software
  • Building a Grounded Search Agent With Foundry, Azure AI Search, and Cosmos DB, Containerized With Docker and Observed With Grafana

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Integrate an H2 Database in Your Spring Boot App

Integrate an H2 Database in Your Spring Boot App

You have created a Spring Boot application and would like to integrate with an H2 database. What do you do?

By 
Jose Praveen
·
Jan. 01, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
280.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

In this tutorial, we will be integrating the H2 database in your Spring Boot application. Note that the H2 database is in the embedded mode.

You have created a Spring Boot application and would like to integrate with an H2 database.

In pom.xml, add the below dependency:

 <!-- H2 Database -->
 <dependency>
 <groupId>com.h2database</groupId>
 <artifactId>h2</artifactId>
 </dependency>

In the application.properties file, add the below line to enable the H2 database:

# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2

# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

Take a Maven build and run the application as a Spring Boot app.

Open a browser and type http://localhost:8080/h2 to get the below image.

h2databasejosepraveen

The yellow highlighted lines should match your application.properties file.

h2databasejosepraveen1

That's it! If you get stuck, kindly comment below.

Spring Framework Spring Boot Database app Integration

Published at DZone with permission of Jose Praveen. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Spring Config Integration With a PCF Application: A Step-by-Step Guide
  • Integrate Spring With Open AI
  • Enterprise RIA With Spring 3, Flex 4 and GraniteDS

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook