Get the App
SLTechnology News&Howtos  ›  Database  › 

Java manipulates MongoDB_2 (applies scene settings)

Shulou Source: shulou.com Published: 2022-06-01 11:14:43 10月04日 Update

Apply scene settin

Take the student information management system as an example to demonstrate the addition, deletion, modification and query of student information. Here, the student's Bean class is defined as:

Student.java

Public class Student {

Private String studentId

Private String name

Private int weight

Private int height

Private Date birthday

Public String getStudentId () {

Return studentId

}

Public void setStudentId (String studentId) {

This.studentId = studentId

}

Public String getName () {

Return name

}

Public void setName (String name) {

This.name = name

}

Public int getWeight () {

Return weight

}

Public void setWeight (int weight) {

This.weight = weight

}

Public int getHeight () {

Return height

}

Public void setHeight (int height) {

This.height = height

}

Public Date getBirthday () {

Return birthday

}

Public void setBirthday (Date birthday) {

This.birthday = birthday

}

@ Override

Public String toString () {

Return "Student [studentId=" + studentId + ", name=" + name

+ ", weight=" + weight + ", height=" + height + ", birthday="

+ birthday + "]"

}

Public Student (String studentId, String name, int weight, int height

Date birthday) {

Super ()

This.studentId = studentId

This.name = name

This.weight = weight

This.height = height

This.birthday = birthday

}

Public Student () {

}

}

The API for adding, deleting, modifying and querying students is defined as follows:

IStudentDao.java

Public interface IStudentDao {

Void insert (Student s)

Void update (Student s)

Void delete (String studentId)

}

The API implementation file for manipulating MongoDB is as follows

IStudentDaoImpl.java

Public class IStudentDaoImpl implements IStudentDao {

@ Override

Public void insert (Student s) {

/ / not implemented yet

}

@ Override

Public void update (Student s) {

/ / not implemented yet

}

@ Override

Public void delete (String studentId) {

/ / not implemented yet

}

}

Tags: Students information interfaces scenarios applications files management systems systems presentations management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Microsoft NVidia Linux macOS