You can also user limit keyword in query. see below query
select * from FileShare limit 3 offset 3
if in your application limit and offset can be assign dynamically by user the use below query
@Autowired
private JdbcTemplate template;
public JdbcTemplate getTemplate() {
return HibernateUtil.getJdbcTemplate();
}
public List<FileShare> getAllSharedFiless(int limit,int offset)
throws ShareMeException {
String query="select * from FileShare limit ? offset ?";
return getTemplate().query(query,
new SharedFilesRowMapper(),
new Object[]{limit,offset});
}
Here FileShare
is a table name and SharedFilesRowMapper
is rowMapper which list rows from table.
PreparedStatementCreator
, I'm new to Spring... – Benniebenning