Book Management System ((JSP + JDBC + Servlet)) Implementation-04: Entity class for establishing database (pojo)

01: Process analysis and database table building phase
02: Write and configure filters (to prevent garbled pages)
03: Project construction & tool class implementation & dependency import
04: Entity class for database establishment (pojo)
05: Realize login function
06: Query all books function
07: Fuzzy query function
08: Implementation of all functions on the page (download source code attached)

1.8 Entity class to establish database (pojo)

Originally, we should create three entity classes, but because the fields of the books and mybooks tables are basically the same, I only created two entity classes.

Insert picture description here

请注意,字段名一定要和数据库的字段名一一对应,我们现在没有使用mybatis,不可以通过配置文件解决属性名和字段名不一致的问题

Book.java

Insert picture description here
package com.tian.pojo;

/**
 * ClassName: Book
 * Description: Book的实体类
 *
 * @author Tianjiao
 * @date 2021/5/28 14:11
 */
public class Book {
    /**
     * 图书编号
     */
    private String bookId;
    /**
     * 图书名
     */
    private String bookName;
    /**
     * 作者
     */
    private String author;
    /**
     * 库存
     */
    private Integer inventory;

    /**
     * 学生学号
     */
    private String stuId;

    public String getStuId() {
        return stuId;
    }

    public void setStuId(String stuId) {
        this.stuId = stuId;
    }

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Integer getInventory() {
        return inventory;
    }

    public void setInventory(Integer inventory) {
        this.inventory = inventory;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookId='" + bookId + '\'' +
                ", bookName='" + bookName + '\'' +
                ", author='" + author + '\'' +
                ", inventory=" + inventory +
                '}';
    }
}

Insert picture description here

Student.java

package com.tian.pojo;

/**
 * ClassName: Student
 * Description: Student的实体类
 *
 * @author Tianjiao
 * @date 2021/5/28 14:11
 */
public class Student {
    /**
     * 学号
     */
    private String stuId;
    /**
     * 学院
     */
    private String college;
    /**
     * 专业
     */
    private String profession;
    /**
     * 学生姓名
     */
    private String stuName;
    /**
     * 入学年份
     */
    private String startYear;
    /**
     * 性别
     */
    private String gender;

    /**
     * 密码
     */
    private String password;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getStuId() {
        return stuId;
    }

    public void setStuId(String stuId) {
        this.stuId = stuId;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public String getStartYear() {
        return startYear;
    }

    public void setStartYear(String startYear) {
        this.startYear = startYear;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuId='" + stuId + '\'' +
                ", college='" + college + '\'' +
                ", profession='" + profession + '\'' +
                ", stuName='" + stuName + '\'' +
                ", startYear='" + startYear + '\'' +
                ", gender='" + gender + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}