I do have a resultset,which I need to validate only some fields and then update to another table,Really I dont know how to validate it and pass back to the orginal resultset?Is there any way to do it in a better perspective.I do have huge data,so I need to also consider the perfomance
while (rs.next()) {
dataValidation.insertRegDataValidation(rs);
}
where the insertRegDataValidation(rs) is method where validation occurs,and if validations returns false,I dont want to update the table,instead of that I want to throw Error,Does any one know any better concepts regarding the same.I never wants to use any frameworks,and to do it in java in an optmized way
If the resultset is not huge; you can firstly use ResultSet object to iterate on all resultSet –> do validation on each result –> passing records are put in an ArrayList.
When above iteration finishes ; iterate on this arrayList and you can use same resultSet object to execute inserts..
Other approach can be to use two resultSets. One for Selecting ; while other for all inserts.