Member-only story

Spring Boot Rest API using JDBC Core

Eric Anicet
11 min readNov 25, 2024

In this story, we’ll learn how to implement a Spring Boot Rest API using Spring Boot JDBC core classes and PostgreSQL.

· Prerequisites
· Overview
What is JDBC (Java Database Connectivity)?
Core Classes and Interfaces for Spring JDBC
· Getting Started
Define Data Model
JDBC Repositories
Spring Rest APIs Controller
· Test the application
· Conclusion
· References

Prerequisites

This is the list of all the prerequisites:

  • Spring Boot 3+
  • Maven 3.6.3
  • Java 21
  • PostgreSQL

Overview

What is JDBC (Java Database Connectivity)?

Java Database Connectivity (JDBC) is an application programming interface (API) for the Java programming language which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented toward relational databases. A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source in the Java virtual machine (JVM) host environment.

https://en.wikipedia.org/wiki/Java_Database_Connectivity

Core Classes and Interfaces for Spring JDBC

The core JDBC classes in Spring Boot provide several mechanisms to simplify database access and interaction.

  1. JdbcTemplate

JdbcTemplate is the central class in the JDBC core package. It handles the creation and release of resources, which helps you avoid common errors, such as forgetting to close the connection. It performs the basic tasks of the core JDBC workflow (such as statement creation and execution), leaving application code to provide SQL and extract results.

@Autowired
private JdbcTemplate…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (1)

Write a response

Great article !! I have a question: which scenario you think is best fit use jdbccore or ORM?