scheduledao.java

来自「accp s1毕业项目 考试管理系统」· Java 代码 · 共 46 行

JAVA
46
字号
package com.exam.db.dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.exam.db.bean.Schedule;
import com.yutang.dboption.DBOption;
import com.yutang.dboption.IPreparedStatementSetter;

public class ScheduleDao {
	List<Schedule> list = new ArrayList<Schedule>();
	DBOption<Schedule> db = new DBOption<Schedule>();
	
	public int insertSchedule(final Schedule schedule){
		int result = 0;
		db.setCon(MyConnection.getConnection(ScheduleDao.class));
		String sql = "insert into Schedule values (?,?,?)";
		result = db.save(sql,new IPreparedStatementSetter(){
			public PreparedStatement setValues(PreparedStatement pst)
					throws SQLException {
				pst.setString(1,schedule.getBanJiID());
				pst.setInt(2,schedule.getCouID());
				pst.setString(3,schedule.getTeaID());
				return pst;
			}			
		});
		return result;
	}
	
	public List<Schedule> selectAllByBanJiID(final Schedule schedule){		
		db.setCon(MyConnection.getConnection(ScheduleDao.class));
		String sql = "select * from Schedule where BanJiID = ?";
		list = db.queryAll(sql, schedule, new IPreparedStatementSetter(){
			public PreparedStatement setValues(PreparedStatement pst)
					throws SQLException {
				pst.setString(1, schedule.getBanJiID());
				return pst;
			}
			
		});
		return list;
	}
}

⌨️ 快捷键说明

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