JDBCTemplate 分页查询

来源:互联网 发布:刀剑神域源码记录下载 编辑:程序博客网 时间:2024/05/01 01:59
jt.query(sql, args, new ResultSetExtractor(){@Overridepublic Object extractData(ResultSet rs) throws SQLException, DataAccessException {int currentRow = 0;int columnCount = rs.getMetaData().getColumnCount();while (rs.next() && (currentRow < (startRow + pageSize))) {if (currentRow >= startRow) {Map<String, Object> tempRow = new HashMap<String, Object>();for (int i = 1; i <= columnCount; i++) {tempRow.put(rs.getMetaData().getColumnName(i), rs.getObject(i));}rsList.add(tempRow);}currentRow = currentRow + 1;}return rsList;}});

0 0