title: Read CSV file and check if contents exists in DB and then only insert else update
body: <p>I am trying to read an uploading CSV file content and want to check if the Upload data having combinations of </p>
  
  <p>“Id + Version (Actual, Budget, Forecast)+Year” </p>
  
  <p>then should delete the existing record in DB having that combo and upload it.</p>
  
  <p>Please help me how to check that,currently I have read all contents in my uploaded csv file using,</p>
  
  <pre><code>  while(fileItemsIterator.hasNext()){
  
    FileItem fileItem = fileItemsIterator.next();
  
    String fileValue=fileItem.getString();//This returns all my csv content
  
      }
  </code></pre>
  
  <h2>DB Call</h2>
  
  <pre><code>   String existingUploadData ="SELECT ID,AMOUNT_TYPE,COST_YEAR FROM UPLOAD WHERE ID ='"+id+"'";
  
               log.debug ("====existingUploadData QUERY== "+existingUploadData );  
  
               PreparedStatement ps = (OraclePreparedStatement) DBConnect.getConnection().prepareStatement(existingUploadData);
  
               ResultSet  rs=ps.executeQuery();
  
               if(rs.next()) {
                      if(rs.getString("ID").equals(fileValue.contains("675"+""+""))) {
  
         //UPDATE EXISTING TABLE
                      }
                  } else {
  
         //INSERT SQL
                  }
  </code></pre>
  
  <p><strong>File Contents</strong></p>
  
  <pre><code>CSV FILE CONTENT SAMPLE
  ----------------------------
  
  ID  |Cost Type| Year|   Leve1        |Level 2         |  I/P      | Vendor Type |   Vendor Name |  App.Ref  Remarks Amount  Unit
  ----|---------|-----|----------------|----------------|-----------|-------------|---------------|----------------------------------
  675 |Actual   |2018 |   TCO Cost     |Solution Support|initiative|  3rd part    |   ABC         |   123      okk     22     EUR
  675 |Actual   |2018 |  Net Book Value|  Software      |Project    | 3rd part    |   XYZ         |   234      good   11      EUR
  675 |Actual   |2018 |   Number of FTE|  BUIT          | Project   | 3rd part    |    LMN        |   435      fine   50      FTE
  </code></pre>
  
  <p>Please help me how to check if 675+Actaul+2018 from CSV file already exists in my database and then do all CRUD operations accordingly.</p>