用于封装数据库数据的JavaBean(实体类)

JavaBean:标准的Java类

实体类是与数据库表一一对应

  1. 要求:

    1. 类必须被public修饰
    2. 必须提供空参的构造器
    3. 成员变量必须使用private修饰
    4. 提供公共setter和getter方法
    
  2. 功能:封装数据

import java.io.Serializable;
//implements Serializable 操作dbutil时需要实现序列化
public class User implements Serializable {
     
    private int uid;
    private String uname;
    private String upwd;
    private String usex;
    private String uhobbey;
    private String utext;

    public User() {
     
    }

    public User(int uid, String uname, String upwd, String usex, String uhobbey, String utext) {
     
        this.uid = uid;
        this.uname = uname;
        this.upwd = upwd;
        this.usex = usex;
        this.uhobbey = uhobbey;
        this.utext = utext;
    }

    public User(String uname, String upwd, String usex, String uhobbey, String utext) {
     
        this.uname = uname;
        this.upwd = upwd;
        this.usex = usex;
        this.uhobbey = uhobbey;
        this.utext = utext;
    }

    public int getUid() {
     
        return uid;
    }

    public void setUid(int uid) {
     
        this.uid = uid;
    }

    public String getUname() {
     
        return uname;
    }

    public void setUname(String uname) {
     
        this.uname = uname;
    }

    public String getUpwd() {
     
        return upwd;
    }

    public void setUpwd(String upwd) {
     
        this.upwd = upwd;
    }

    public String getUsex() {
     
        return usex;
    }

    public void setUsex(String usex) {
     
        this.usex = usex;
    }

    public String getUhobbey() {
     
        return uhobbey;
    }

    public void setUhobbey(String uhobbey) {
     
        this.uhobbey = uhobbey;
    }

    public String getUtext() {
     
        return utext;
    }

    public void setUtext(String utext) {
     
        this.utext = utext;
    }

    @Override
    public String toString() {
     
        return "User{" +
                "uid=" + uid +
                ", uname='" + uname + '\'' +
                ", upwd='" + upwd + '\'' +
                ", usex='" + usex + '\'' +
                ", uhobbey='" + uhobbey + '\'' +
                ", utext='" + utext + '\'' +
                '}';
    }

}

你可能感兴趣的:(javaWeb)