teacherbean.java

来自「学生信息管理系统 jsp + sql + javabean 实现」· Java 代码 · 共 95 行

JAVA
95
字号
package sms.bean;

import java.io.Serializable;
import sms.db.DBAccess;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class TeacherBean implements Serializable {
    private String college;
    private String description;
    private String id;
    private String name;
    private String sex;
    private String title;
    public String getCollege() {
        return college;
    }

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

    public void setTitle(String title) {
        this.title = title;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getSex() {
        return sex;
    }

    public String getTitle() {
        return title;
    }

    public ArrayList queryTeacherInfo(String college,String id){
        String sql = "select * from teach_info where 1=1";
        if(college != null && college.length() > 0)
            sql += " and college='"+college+"'";
        if(id != null && id.length() > 0)
            sql += " and id='"+id+"'";
        DBAccess dba = new DBAccess();
        ArrayList aList = new ArrayList();
        try {
            dba.getConnection();
            ResultSet rs = dba.query(sql);
            if (rs != null) {
                while (rs.next()) {
                TeacherBean teacherBean = new TeacherBean();
                teacherBean.setCollege(rs.getString("college"));
                teacherBean.setDescription(rs.getString("description"));
                teacherBean.setId(rs.getString("id"));
                teacherBean.setName(rs.getString("name"));
                teacherBean.setSex(rs.getString("sex"));
                teacherBean.setTitle(rs.getString("title"));
                aList.add(teacherBean);
                }
            }
            return aList;
        } catch (SQLException ex) {
            return null;
        }finally{
          dba.closeConnection();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?