Javatpoint Logo
Javatpoint Logo

Spring Boot JDBC

Spring Boot provides starter and libraries for connecting to our application with JDBC. Here, we are creating an application which connects with Mysql database. It includes the following steps to create and setup JDBC with Spring Boot.

Create a database

Create a table in to mysql

Creating a Spring Boot Pproject

Spring Boot jdbc 1

Providing project name and other project related information.

Spring Boot jdbc 2

Providing dependencies

Spring Boot jdbc 3

After finishing, create following files in your project.

Configure database into application.properties file.

// application.properties

// SpringBootJdbcApplication.java

Creating a controller to handle HTTP requests.

// SpringBootJdbcController.java


Run the application

Run SpringBootJdbcApplication.java file as Java application.

Spring Boot jdbc 4

Now, open browser and follow the following URL.

Spring Boot jdbc 5

It says data has inserted successfully. let?s confirm it by checking mysql table.

Spring Boot jdbc 6

Well, our application is working fine. Now, we can perform other database operations as well.


Next Topic#




Please Share

facebook twitter google plus pinterest tumbler

Learn Latest Tutorials