Java, Software Development, Spring Boot

Quickly Create a Spring Boot JDBC Application

We can create a Spring Boot application that uses JDBC as quickly as making its JPA variant without hassle. But no doubt, JDBC applications are much faster than those relying on ORM technology. For many, the idea of a JDBC application evokes unpleasant experiences, memory, or gossip about low-level programming with the JDBC API. With Spring Boot, that is no longer the case. However, there is a minor setback – we will be working with SQL statements. In addition to that, our codebase size could be humongous. Also, some layer components eventually become not readily reusable. Worse and, as a result, the whole codebase became unwieldy.

Create a Spring Boot JDBC Application With Spring Initializr

To create a Spring Boot JDBC application with Spring Initializr, we only need to choose two dependencies – Spring Data JDBC and the corresponding driver for the RDBMS (e.g., MySQL) we intend to use.

What’s inside our pom.xml

Once we extracted the project that the Spring Initializr had generated, we can examine the content of the pom.xml file. In the file, we only have two dependencies that we included via the Spring Initializr.

Similar to creating a Spring Boot JPA application with the Spring Initializr, we get the minimum possible number of files, consisting of a Java file,, and pom.xml. We can ignore the unit test class file in this context.

Configure and Use Spring Boot JDBC Application

Lastly, we modify the empty file with the following settings.

To run queries or updates against the database, we can use either a JdbcTemplate or NamedParameterJdbcTemplate.

Wasn’t that easy? It wasn’t as hellish as you had imagined.

We may start with using JPA for our Spring Boot application. But it does not mean we’ll stick with JPA forever. We can always migrate to JDBC without hassle, at least at the persistent layer. Then, we will work our way up until our Spring Boot application entirely moves away from JPA.


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like