The below method will insert a List of student recors.
public void insertListOfPojos(final List myPojoList) {
String sql = "INSERT INTO " + "Student " + "(name,age) " + "VALUES "
+ "(?,?)";
jdbcTemplateObject.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
Student myPojo = myPojoList.get(i);
ps.setString(1, myPojo.getName());
ps.setInt(2, myPojo.getAge());
}
@Override
public int getBatchSize() {
return myPojoList.size();
}
});
}
Problem :- Say if the values of a column in 5 record is too large then the execution stops. I want the execution to continue even if the insertion of 5th record fails.