Newer
Older
import edu.ncsu.csc.itrust.beans.CDCStatsBean;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class CDCStatsBeanLoader implements BeanLoader<CDCStatsBean> {
public PreparedStatement loadParameters(PreparedStatement ps, CDCStatsBean bean) throws SQLException {
int i = 1;
ps.setInt(i++, bean.getSex());
ps.setFloat(i++, bean.getAge());
ps.setDouble(i++, bean.getL());
ps.setDouble(i++, bean.getM());
ps.setDouble(i++, bean.getS());
return ps;
}
public CDCStatsBean loadSingle(ResultSet rs) throws SQLException {
CDCStatsBean stats = new CDCStatsBean();
stats.setSex(rs.getInt("sex"));
stats.setAge(rs.getFloat("age"));
stats.setL(rs.getDouble("L"));
stats.setM(rs.getDouble("M"));
stats.setS(rs.getDouble("S"));
return stats;
}
public List<CDCStatsBean> loadList(ResultSet rs) throws SQLException {
ArrayList<CDCStatsBean> list = new ArrayList<CDCStatsBean>();
while (rs.next()) {
list.add(loadSingle(rs));
}
return list;
}
}