控制器类调用:
List<FOO> fooList = fooDao.getFooList(String.valueOf(branchId),customerId,String.valueOf(systemIndex));
被调用的 Dao 类方法:
public List<FOO> getFooList(String index_branch,String index_cust,String index_sys)
{
// Object[] helo= new Object[10];
System.out.println("branchId -> " +index_branch+ "customerId -> " +index_cust+ " systemId -> " +index_sys);
return db.query("select * from tb_foo where branch=? and customer=? and system=?",new RowMapper<FOO>() {
@Override
public FOO mapRow(ResultSet rs, int i) throws SQLException {
FOO foo = new FOO();
foo.setPi(rs.getInt("foo_pi"));
foo.setIndex(rs.getInt("foo_index"));
foo.setFooName(rs.getString("foo_name"));
foo.setFooValue(""+rs.getInt("foo_value"));
return foo;
}
},index_branch,index_cust,index_sys);
}
使用CommandLine
客户端提供的查询返回数据库中的值列表,但RowMapper
不返回。我检查了 fooDao 是否返回 null,但不是。在行返回时获取空指针异常db.query(...);