JDBCTemplate 分页查询

jt.query(sql, args, new ResultSetExtractor(){
			@Override
			public 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 tempRow = new HashMap();
						for (int i = 1; i <= columnCount; i++) {
							tempRow.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
						}
						rsList.add(tempRow);
					}
					currentRow = currentRow + 1;
				}
				return rsList;
			}
			
});

你可能感兴趣的:(数据库)