Jul 6th, 2011, 10:07 AM
how to validate data formate befre pushing in to data base from csv file.
I have an application which is reading data from csv file and push in to data base. But I want to check the data formate before push in to database. Whether the data formate is correct or wrong. if the data is correct then this should push in to data base. if the data is wrong then this should push in to failed csv file. (please remember the data formate is only data types like int, string, date like that).
Can any body help on this!
Jul 7th, 2011, 05:36 AM
I also have the same issue... I need to check first if the data (may it be the type or the format or if there are null elements) before pushing them to the database... At first, I was thinking of reading the file first (separately from the ItemReader) to check and validate the data in the file. But that would mean a wastage of resources (redundancy of reading the file) and it can take a lot longer if the file is so big.
I am trying another approach though: skipping items, instead of dropping the whole job/file, by using SkipListener, and logging the skipped files on an another table on the database.. But I am still configuring and setting it up to work on my project, and I am having a hard time on it. <newbie me! >
If you want to try it out, you can check on Alain's blog on Batch Tutorials: http://alain-cieslik.com/
Here's the direct link to the tutorial on SkipListener: http://alain-cieslik.com/2011/06/16/...in-a-database/