资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Java操纵MongoDB_2(应用场景设置)

应用场景设置

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了黄冈免费建站欢迎大家使用!

以学生的信息管理系统为例,演示学生信息的增删改查。这里定义学生的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() {

}

}

并且定义了学生的增删改查接口如下:

IStudentDao.java

public interface IStudentDao {

void insert(Student s);

void update(Student s);

void delete(String studentId);

}

操纵MongoDB的接口实现文件如下,

IStudentDaoImpl.java

public class IStudentDaoImpl implements IStudentDao{

@Override

public void insert(Student s) {

//暂未实现

}

@Override

public void update(Student s) {

//暂未实现

}

@Override

public void delete(String studentId) {

//暂未实现

}

}



新闻标题:Java操纵MongoDB_2(应用场景设置)
网址分享:http://cdkjz.cn/article/gchcpc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220