One way is to:
1. retrieve all records from I/P table in a List object
2. Create sql string
3. Create BatchPreparedStatementSetter
- where public int getBatchSize(){
return objList.size();
}
- And public void setValues(PreparedStatement ps, int index) throws SQLException{
Record rec = (Record)objList.get(index);
ps.setString(1,rec.getFirst());
ps.setString(2,rec.getFirst());
}
4. jdbcTemplate.batchUpdate(sql,setter);
But the concern is I/P table may have >50K records so don't want to get in a List. I have little knowledge about is it good to retrieve such a huge data in a List. Is there any other way where I can retrieve each record and pass it to the BatchPreparedStatementSetter without getting the List involved? And if data retrieving into List is the only way to get it done, then kindly let me know how can I control the block wise insertion. Highly appreciated if I can get some code snippet.
I m using JDBCTemplate within DBBaseObject for data access operation.
Thanks.
Prem


Reply With Quote