scbushan05 / springboot-jdbctemplate-rest-api-mysql

This is the example that shows you how to build spring boot REST API that connects to MySQL database using Spring JdbcTemplate

Home Page:https://bushansirgur.in/spring-boot-jdbctemplate-crud-operations-mysql/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Boot REST API

This is the example project that shows you how to build Spring boot REST API that connects to MySQL databse using Spring JdcbTemplate.

Features

  • Create employee
  • List all employees
  • Fetch single employee by id
  • Update employee by id
  • Delete employee by id

API Reference

We will create a Employee REST API, following are the rest end points

Get all employees

  GET /api/v1/employees

Sample Response

  [
    {
        "id": 1,
        "name": "Bushan",
        "location": "India",
        "department": "IT"
    },
    {
        "id": 2,
        "name": "Bharath",
        "location": "India",
        "department": "Sales"
    },
    {
        "id": 3,
        "name": "Chaitra",
        "location": "India",
        "department": "IT"
    }
]

Get single employee

  GET /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to fetch

Sample Response

{
    "id": 2,
    "name": "Bharath",
    "location": "India",
    "department": "Sales"
}

Save employee

  POST /api/v1/employees
Parameter Type Description
employee reference Employee Required. Request body of employee

Sample Request

{
    "name": "Bharath",
    "location": "India",
    "department": "Sales"
}

Update employee

  PUT /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to update
employee reference Employee Required. Request body of employee

Sample Request

{
    "name": "Bharath",
    "location": "India",
    "department": "Sales"
}

Delete employee

  DELETE /api/v1/employees/${id}
Parameter Type Description
id int Required. Id of employee to delete

Installation

Download the project and import it to any IDE. Open the class SpringbootjdbcApplication.java and run as Java application.

Demo

Insert gif or link to demo

Authors

Related

Here are some related projects

Awesome README

About

This is the example that shows you how to build spring boot REST API that connects to MySQL database using Spring JdbcTemplate

https://bushansirgur.in/spring-boot-jdbctemplate-crud-operations-mysql/


Languages

Language:Java 100.0%