How to handle Database in Spring Boot
Hamdamboy
Posted on May 8, 2020
Core data for Spring Boot with Database. Please you may use more source in there link.
This provides Database implementation in the Spring Boot. Especially, we'll briefly inform here concept of Spring, Spring Boot, JDBC, JPA, H2 and result of our experience project(there is link using github).
Spring
The Spring Framework is an application framework and inversion of control container for the Java platform. Spring is HA (high avilability).
Spring Boot
Most Spring Boot applications need minimal Spring configuration. Features. Create stand-alone Spring applications
JPA
JPA (The Java Presistence API) = This module deals with enhanced support for JPA based data access layers.Indeed, the JPA is set of the rules to interfaces.
- JPA follows Object-Relation Mapping (ORM). It is a set of interfaces. It also provides a runtime EntityManager API for processing queries and transactions on the objects against the database. It uses a platform-independent object-oriented query language JPQL (Java Persistent Query Language). Why should we use JPA? JPA is simpler, cleaner, and less labor-intensive than JDBC, SQL, and hand-written mapping. JPA is suitable for non-performance oriented complex applications.
API (Application programming interface) is a document that contains a description of all the features of a product or software. It represents classes and interfaces that software programs can follow to communicate with each other. An API can be created for applications, libraries, operating systems, etc.
JPA Implementations JPA is an open-source API. There is various enterprises vendor such as Eclipse, RedHat, Oracle, etc. that provides new products by adding the JPA in them. There are some popular JPA implementations frameworks such as Hibernate, EclipseLink, DataNucleus, etc. It is also known as Object-Relation Mapping (ORM) tool.
JDBC
Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database.
Architecture of the Project Implementation.
H2
- H2 is a relational database management system written in Java. It can be embedded in Java applications or run in client-server mode.
Spring Boot + JPA + Hibernate + MySQL|Oracle
Real project configuration. Source.
Create a Maven Project
You may use your tool(Eclipse, IntelliJ Idea, etc.), this example we used IntelliJ then create a new Maven project and name it SpringJDBC.
At the end of this tutorial, we’ll get the following project structure:
POM.XML
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
Posted on May 8, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.