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
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Spring Config Integration With a PCF Application: A Step-by-Step Guide
  • How to Build a Chat App With Spring Boot and DynamoDB
  • Integration Between Java and Slack With Webhooks

Trending

  • A Modern Stack for Building Scalable Systems
  • Ensuring Configuration Consistency Across Global Data Centers
  • Monolith: The Good, The Bad and The Ugly
  • How to Merge HTML Documents in Java
  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 user avatar
Jose Praveen
·
Jan. 01, 17 · Tutorial
Likes (23)
Comment
Save
Tweet
Share
280.1K Views

Join the DZone community and get the full member experience.

Join For Free

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, DZone MVB. 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
  • How to Build a Chat App With Spring Boot and DynamoDB
  • Integration Between Java and Slack With Webhooks

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!