首页>代码>java swing开发图书馆管理系统>/Librarians/src/data/ReaderDao.java
package data;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import entity.Reader;

public class ReaderDao {
	//根据读者编号,获得单个读者实体
	public static Reader selectReader(String id) {
		String sql = "select *  from reader where id='" + id +"'";
		ResultSet rs = BaseDao.executeQuery(sql);
		Reader reader = null;
		try {
			if (rs.next()) {
				reader = new Reader();
				reader.setId(rs.getString("id"));
				reader.setType(rs.getString("type"));
				reader.setName(rs.getString("name"));
				reader.setSex(rs.getString("sex"));
				reader.setMax_num(rs.getString("max_num"));
				reader.setDays_num(rs.getInt("days_num"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		BaseDao.close();
		return reader;
	}
	
	//获得满足sql语句的读者实体列表
	public static List selectReaderList(String sql) {
		List list = new ArrayList();
		ResultSet rs = BaseDao.executeQuery(sql);
		Reader reader = null;
		try {
			while (rs.next()) {
				reader = new Reader();
				reader.setId(rs.getString("id"));
				reader.setType(rs.getString("type"));
				reader.setName(rs.getString("name"));
				reader.setSex(rs.getString("sex"));
				reader.setMax_num(rs.getString("max_num"));
				reader.setDays_num(rs.getInt("days_num"));
				list.add(reader);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		BaseDao.close();
		return list;
	}
}
最近下载更多
微信网友_6445756515635200  LV3 2023年12月21日
KAIzx11  LV7 2023年6月24日
huangzy  LV12 2023年6月11日
122378  LV3 2022年12月14日
微信网友_6191697646571520  LV6 2022年10月31日
13112360  LV2 2022年9月20日
gnnhka  LV10 2022年6月16日
fantesy  LV17 2022年5月15日
喃喵xxxx  LV6 2022年5月11日
543666826  LV33 2022年3月12日
最近浏览更多
akittyboy  LV9 3月22日
asddwh  LV12 2023年12月26日
求学的熊猫  LV6 2023年12月25日
微信网友_6786215447367680  LV4 2023年12月21日
微信网友_6445756515635200  LV3 2023年12月21日
weilaizhisheng  LV21 2023年12月5日
1143011510  LV15 2023年11月27日
李朝磊  LV18 2023年11月18日
夜猫子111  LV2 2023年11月6日
sunshine9920  LV12 2023年10月23日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友