Files
StudentController.javaStudentRepository.javaStudentH2Service.javaStudentRowMapper.javaStudent.java
And also given a database file school which contains a student table. The student table initially contains details of 20 students.
| Columns | Type |
|---|---|
| studentId | INTEGER |
| studentName | TEXT |
| gender | TEXT |
| standard | INTEGER |
Use only STUDENT as a table name in your code while writing queries.
-
Student.java:Studentclass should contain the following attributes.Attribute Type studentId int studentName String gender String standard int -
StudentRepository.java: Create aninterfacecontaining required methods. -
StudentH2Service.java: Update the service class with logic for managing student data. -
StudentController.java: Create the controller class to handle HTTP requests. -
StudentRowMapper.java: Create a class which implements theRowmapper Interface.
Implement the following APIs.
Returns a list of all students in the school.
[
{
"studentId": 1,
"studentName": "John",
"gender": "Male",
"standard": 1
},
...
]
Creates a new student in the student table. The studentId is auto-incremented. Also, returns the student details added.
{
"studentName": "Prince",
"gender": "Male",
"standard": 4
}
{
"studentId": 21,
"studentName": "Prince",
"gender": "Male",
"standard": 4
}
Creates multiple students in the student table and returns a text containing the numbers of students added.
For example, the below request object contains details of 4 students.
[
{
"studentName": "Jack",
"gender": "Male",
"standard": 8
},
...
]
Successfully added 4 students
The controller method that handles this API 3 consists of the parameter of type ArrayList<Student>.
Returns a student based on the studentId. If the given studentId is not found in the student table, raise ResponseStatusException with HttpStatus.NOT_FOUND.
{
"studentId": 13,
"studentName": "Olivia",
"gender": "Female",
"standard": 3
}
Updates the details of a student in the student table based on the studentId. Also, return the updated student details from the student table using the studentId.
{
"studentName": "Yuvi"
"gender": "Male",
"standard": 6
}
{
"studentId": 3,
"studentName": "Yuvi",
"gender": "Male",
"standard": 6
}
Deletes a student from the student table based on the studentId.
Do not modify the code in SchoolApplication.java