1. 程式人生 > >查詢資料庫的 sql語句 返回欄位 和類 屬性的關係

查詢資料庫的 sql語句 返回欄位 和類 屬性的關係

資料庫的資料表

實體類

package exer;

public class Student {
	//流水號
	private int flowId;
	//考試的型別
	private int type;
	//身份證號
	private String idCard;
	//准考證號
	private String examCard;
	//學生名
	private String studentname;
	//學生地址
	private String location;
	//考試成績
	private int grade;
	
	public Student() {
		super();
	}

	public Student(int flowId, int type, String idCard, String examCard, String studentname, String location,
			int grade) {
		super();
		this.flowId = flowId;
		this.type = type;
		this.idCard = idCard;
		this.examCard = examCard;
		this.studentname = studentname;
		this.location = location;
		this.grade = grade;
	}

	public int getFlowId() {
		return flowId;
	}

	public void setFlowId(int flowId) {
		this.flowId = flowId;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public String getExamCard() {
		return examCard;
	}

	public void setExamCard(String examCard) {
		this.examCard = examCard;
	}

	public String getStudentname() {
		return studentname;
	}

	public void setStudentname(String studentname) {
		this.studentname = studentname;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	@Override
	public String toString() {
		return "Student [flowId=" + flowId + ", type=" + type + ", idCard=" + idCard + ", examCard=" + examCard
				+ ", studentname=" + studentname + ", location=" + location + ", grade=" + grade + "]";
	}
	
}
查詢資料表的sql 語句
String sql = "SELECT flow_id flowId,type,id_card idCard,"
					+ "exam_card examCard,student_name studentName,"
					+ "location,grade FROM examstudent WHERE flow_id = ?";