Read a .dat file in java and compare with Database table result : <p>My Requirement is we get .dat files from developers, We need to verify if the .dat files and database table result are same</p>

<p>Sample .dat file looks like</p>

<p>3009706~~F18130000010~~R60629572~~0~~936~~1~~PA4~~PA3~~~~~~~~~~~~~~Y~~
3009712~~F18130000020~~R50160248~~0~~430~~1~~PA4~~PA3~~~~~~~~~~~~~~Y~~
3009723~~8062229458PM~~R99999999~~0~~439~~1~~PA4~~PA3~~~~~~~~~~~~~~Y~~
3009728~~8028190839PM~~R57884273~~0~~936~~1~~PA4~~PA3~~~~~~~~~~~~~~Y~~</p>

<p>Sample Database table </p>

<p><a href="https://i.stack.imgur.com/TMa1r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMa1r.png" alt="enter image description here"></a></p>

<p>I need to read each row from .dat files, query the database with the first value which is primary key and compare the db result with the .dat file result. each column is separated by ~~ symbol. Like wise i need to compare all rows with database results.</p>

<p>Like wise i have many files. So one table one .dat file. Manual Comparison is taking hell lot of effort . Need to automate this process
Steps i am thinking is</p>

<ol>
<li>take the count of rows in .dat file and compare with the count of database</li>
<li>Read row by row in data file and capture all the values and using primary key query the database table with that primary key to get the result. </li>
<li>Compare the result with the .dba file row. If the data is null in db, there is no entry in .dat file, ALso need to verify if ~~ is present for each column separation.</li>
</ol>

<p>Please provide me any idea or code to start with in java</p>

<p>Thanks in Advance</p>
