计算机毕业设计主要代码2:
//循环把结果集的记录存入数组中
while (rs.next()) {
ms[i] = new ModelOne();
ms[i].setId(rs.getString(1));
ms[i].setIndexid(rs.getString(2));
ms[i].setType(rs.getInt(3));
ms[i].setPerson(rs.getInt(4));
ms[i].setMoney(rs.getFloat(5));
ms[i].setName(rs.getString(6));
ms[i].setTables(rs.getInt(7));
++i;
}
rs.close();
st.close();
return ms; }
//得到收支总和
public ModelFour[] getBalance(int nYear,int nMonth) throws Exception {
st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql = "select a.rectime,SUM(b.money) as money from family_rectime a,mytable b"
+" where a.id=b.indexid and Year(a.rectime)="+nYear+" and Month(a.rectime)="+nMonth
+" and not b.tables=5 group by a.rectime order by DAY(a.rectime)";
ResultSet rs = st.executeQuery(sql);
rs.last();
int row = rs.getRow();
ModelFour[] mf = new ModelFour[row];
rs.beforeFirst();
int i = 0;
//循环取出结果集的内容
while (rs.next()) {
mf[i] = new ModelFour();
mf[i].setRecTime(rs.getString(1));
mf[i].setTotalMoney(rs.getFloat(2));
++i;
}
rs.close();
st.close();
return mf;
}
public ModelTwo getRecTimeResults(String sql) throws Exception {
ModelTwo mt = new ModelTwo();
try
{
st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery(sql);
rs.beforeFirst();
int i = 0;
//循环取出结果集的内容
while (rs.next()) {
mt.setId(rs.getString(1));
mt.setRecTime(rs.getString(2));
System.out.println("/////////////////"+mt.getId());
System.out.println("/////////////////"+mt.getRecTime());
i++;
}
rs.close();
st.close();
return mt;
}
〖资料来源:计算机毕业论文 www.xiaoniu168.com〗
第18页为计算机毕业论文主要代码3......