title: How to efficiently retrieve 2 million records from a DB2 database using Java?
body: <p>I need to retrieve and process around 2 million records from a Db2 database using Java. We are migrating tables from one db to another and so i am trying to do a diff between two tables to check if there is any difference in the data.</p>
  
  <p>Currently i am doing a normal query and getting the data into the resultset and processing it using HashMap's. But its taking forever to process. I did try setting the fetchsize to a decent value(200), but this didn't help either.</p>
  
  <p>Is there any other better way of retrieving the data like getting in chunks and process it?</p>