Sql sql=Sqls.create("SELECT curMonth_shouyi,curYear_shouyi,totalReciveAmount").
setParam("userId", userId);
sql.setCallback(new SqlCallback() {
@Override
public Object invoke(Connection conn, ResultSet rs, Sql sql)
throws SQLException {
Record record=new Record();
while (rs.next()){
record.set("curMonth_shouyi", rs.getInt("curMonth_shouyi"));
record.set("curYear_shouyi", rs.getInt("curYear_shouyi"));
record.set("totalReciveAmount", rs.getInt("totalReciveAmount"));
}
return record;
}
});
dao.execute(sql);
Record record= (Record) sql.getResult();
System.out.println(record.get("curMonth_shouyi"));
System.out.println(record.get("curYear_shouyi"));
System.out.println(record.get("totalReciveAmount"));
return record;
4 回复
只有一条记录?不然这回调的Record的值就是最后一条记录的值
来自炫酷的 NutzCN
再说,写这回调还不如直接用Sqls.callback.records()
来自炫酷的 NutzCN
@wendal 恩,只有一条记录,为啥结果返回3个0
因为就是0咯,打印rs.getInt的值出来肯定也是0
来自炫酷的 NutzCN
添加回复
请先登陆