Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Java manipulates MongoDB_2 (applies scene settings)

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report