溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Java操縱MongoDB_2(應(yīng)用場景設(shè)置)

發(fā)布時間:2020-07-18 11:42:05 來源:網(wǎng)絡(luò) 閱讀:399 作者:huting010527 欄目:MongoDB數(shù)據(jù)庫


應(yīng)用場景設(shè)置

以學(xué)生的信息管理系統(tǒng)為例,演示學(xué)生信息的增刪改查。這里定義學(xué)生的Bean類為:


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() {

}

}

并且定義了學(xué)生的增刪改查接口如下:

IStudentDao.java

public interface IStudentDao {

void insert(Student s);

void update(Student s);

void delete(String studentId);

}



操縱MongoDB的接口實現(xiàn)文件如下,

IStudentDaoImpl.java

public class IStudentDaoImpl implements IStudentDao{


@Override

public void insert(Student s) {

//暫未實現(xiàn)

}


@Override

public void update(Student s) {

//暫未實現(xiàn)

}


@Override

public void delete(String studentId) {

//暫未實現(xiàn)

}

}



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI