0
我看過很多例子,如下所示。但我沒有得到任何解決我的問題。如何使用spring jdbc獲取n個記錄數
我正在使用下面的代碼來獲取所有用戶。
List<User> users = this.jdbcTemplate.query(
"select * from user",
new RowMapper<User>() {
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User();
user.setFirstName(rs.getString("firstname"));
user.setLastName(rs.getString("lastname"));
return user;
}
});
但與上面的代碼的問題是,如果我有10萬條記錄在用戶表中,我將不能夠保持數據的列表。
所以我在jdbcTemplate
上使用fetchSource(100)
函數。 我無法獲取所有記錄,它在兩者之間停止。
請建議該怎麼做。
[編輯] 添加到下面的問題,我索引的數據從oracle數據庫表到精確搜索。我不想一個一個地處理,因爲索引1000萬條記錄會很差。它不是一個Web應用程序,它是獨立的程序,它建立在Spring引導之上。
你想實現什麼? Al記錄或記錄的一部分,您正在使用哪個數據庫... –