Skip to content

This project demonstrates fundamental concepts of Java, Spring, and MySQL by creating a simple application that interacts with a relational database.

Notifications You must be signed in to change notification settings

prathampalsingh/Springboot_Curd_Operations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Spring Boot CRUD Operations with MySQL

This project demonstrates fundamental concepts of Java, Spring Boot, and MySQL by creating a simple application that interacts with a relational database.

Key Features:

  • Spring Boot: Leverages the Spring Boot framework for rapid application development, including dependency injection, auto-configuration, and embedded servers.
  • MySQL: Utilizes MySQL as the underlying database for data storage and retrieval.
  • JPA and Hibernate: Employs Java Persistence API (JPA) and Hibernate as the Object-Relational Mapping (ORM) layer to interact with the database using Java objects.
  • CRUD Operations: Implements core CRUD (Create, Read, Update, Delete) operations on a chosen entity (e.g., a User, Product) through a RESTful API.
  • RESTful API: Exposes endpoints (e.g., GET, POST, PUT, DELETE) for interacting with the data using HTTP requests.

Technical Steps:

  1. Project Setup:

    • Create a Spring Boot project using Spring Initializr.
    • Use Java version 17 or higher and Maven.
    • Add dependencies for:
      • Spring Web
      • Spring Data JPA
      • MySQL Driver
      • Lombok
  2. Project Setup (After Cloning):

    • Run mvn clean install in the terminal to download all dependencies.
  3. Database Setup:

    • Create a database named newdb using the following SQL command:

      create database newdb abcd;
    • Important: Update the username and password in the application.properties file with your MySQL credentials.

  4. Run the Application:

    • Start the Spring Boot application using your preferred IDE or by running mvn spring-boot:run in the terminal.
  5. Explore and Experiment:

    • Use a tool like Postman to interact with the exposed RESTful endpoints.
    • Test the CRUD operations using Postman.
    • Modify the entity, service, and controller classes to explore different functionalities.

Getting Started with Postman:

  1. Install Postman: https://www.getpostman.com/
  2. Create a new collection for your project.
  3. Create Operation:
    • Set the request method to POST.
    • Set the URL to http://localhost:8080/addStd (assuming the application runs on port 8080).
    • In the Body tab, select raw and set the content type to application/json.
    • Provide a JSON object representing the student data you want to create
      {"name": "John Doe","mark": 30}
    • Send the request.
  4. Read Operation:
    • Set the request method to GET.
    • Set the URL to http://localhost:8080/getAllData to retrieve all students.
    • You can also use http://localhost:8080/getStdById/{id} to retrieve a specific student by ID, replacing {id} with the actual student ID.
    • Send the request.
  5. Update Operation:
    • Set the request method to PUT.
    • Set the URL to http://localhost:8080/updStd.
    • In the Body tab, provide a JSON object representing the updated student data.
    • Send the request.
  6. Delete Operation: (Not implemented in this example project):
    • You can implement a DELETE endpoint to remove students from the database. Refer to Spring Data JPA documentation for guidance.

This project provides a solid foundation for understanding core Spring Boot concepts and building more complex applications with database interactions. Result

Student database:

student_newdb

Spring Starting:

student_vs

Post student data in database using postman:

post_req_student

Get Student data by ID in postman:

get_studentbyid

Note:

  • This README file provides a basic overview. For detailed instructions and implementation specifics, refer to the project's source code and comments.
  • This project is intended for educational and learning purposes.

I hope this enhanced README file is more informative and appealing!

About

This project demonstrates fundamental concepts of Java, Spring, and MySQL by creating a simple application that interacts with a relational database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published