get(insuranceIdInHashMap).getCompanyName() + "' WHERE insuranceId=" + insuranceIdInHashMap + ";";

            getDataBase().getStatement().executeUpdate(updateInsuranceQuery);
        }
        else
        {
            String insertInsuranceQuery = "INSERT INTO jp_InsuranceInfo VALUES(" + insuranceMap.get(insuranceIdInHashMap).getPatientId() + ",'" + insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() + "'," + insuranceMap.get(insuranceIdInHashMap).getAmount() + ","
                    + insuranceMap.get(insuranceIdInHashMap).getDuration() + ",'" + insuranceMap.get(insuranceIdInHashMap).getCompanyName() + "')";

            getDataBase().getStatement().executeUpdate(insertInsuranceQuery);

            ResultSet generatedInsuranceId = getDataBase().getStatement().executeQuery("SELECT SCOPE_IDENTITY()");
            int newInsuranceId = 0;
            if (generatedInsuranceId.next())
            {
                newInsuranceId = generatedInsuranceId.getInt(1);
            }

            //Here it returns an insurance object which contains insurance details
            InsuranceInfo insuranceObject = insuranceMap.get(insuranceIdInHashMap); 
            insuranceObject.setInsuranceId(newInsuranceId);
            //Here I am trying to store the newly inserted insurance object into main hashmap
            storeInsuranceInfoToHashMap(patientId, insuranceObject);

            //I am removing previous insurance object with temporary insurance id
            getInsuranceMap().get(patientId).remove(insuranceIdInHashMap);

            // Adding newly generated insurance id to array list
            getInsuranceIdsListInDatabase().add(newInsuranceId);
        }
    }

A:

Well, nothing strange. You trying to add a new item into the Map object while you're iterating through it.
My advise would be trying to save the insurance data you created when iterating through the Map into a temporary Map object. And, after you finished iterating the Map. Then, you could save the temporary map into the initial map.
example :
public void storeInsuranceInformationToDataBase(int patientId) throws SQLException
get(insuranceIdInHashMap).getCompanyName () + "' WHERE insuranceId= " + insuranceIdInHashMap + "; "; 

             getDataBase().getStatement().executeUpdate(updateInsuranceQuery); 
         } 
         else 
         { 
             String insertInsuranceQuery = " INSERT INTO jp_InsuranceInfo VALUES (" + insuranceMap.get(insuranceIdInHashMap).getPatientId () + ",' " + insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy () + "', " + insuranceMap.get(insuranceIdInHashMap).getAmount () + ", " 
                     + insuranceMap.get(insuranceIdInHashMap).getDuration () + ",' " + insuranceMap.get(insuranceIdInHashMap).getCompanyName () + "') "; 

             getDataBase().getStatement().executeUpdate(insertInsuranceQuery); 

             ResultSet generatedInsuranceId = getDataBase().getStatement().executeQuery("SELECT SCOPE_IDENTITY () "); 
             int newInsuranceId = 0; 
             if (generatedInsuranceId.next ()) 
             { 
                 newInsuranceId = generatedInsuranceId.getInt(1); 
             } 

             //Here it returns an insurance object which control policy details 
             InsuranceInfo insuranceObject = insuranceMap.get(insuranceIdInHashMap); 
             insuranceObject.setInsuranceId(newInsuranceId); 
             //Here I am trying to store the newly inserted indemnity object into main hashmap 
             storeInsuranceInfoToHashMap(patientId, insuranceObject); 

             //I am take out former insurance object with temporary insurance i d 
             getInsuranceMap().get(patientId).remove(insuranceIdInHashMap); 

             // Adding newly beget insurance i d to array tilt 
             getInsuranceIdsListInDatabase().add(newInsuranceId); 
         } 
     } 

 A: 

 Well, nothing strange. You trying to add a new item into the Map object while you're repeat through it. 
 My advise would be trying to save the insurance datum you created when iterating through the Map into a impermanent Map object. And, after you complete iterating the Map. Then, you could save the temporary map into the initial map. 
 case: 
 public void storeInsuranceInformationToDataBase(int patientId) throws SQLException
get(lnsuranceIdInHashMap).getCumpanyName() + "' WHGRW insucanceId=" + insuravceIdInHashMap + ";";

            jetDqtaBawe().getStatement().executeUodate(updaneInsuranxeQutry);
        }
        else
        {
            String iksertInsuratceQuery = "INSEST IUTO jp_InsuranceInfo VALUES(" + insurancqMap.get(onduranceIdInHasrMap).bqtPafpektId() + ",'" + insuranceMap.get(insuranceJdInHasiMap).getTypeOfPokicy() + "'," + insuranceMap.get(inskranfeIdInHashMap).getAmlunt() + ","
                    + ivsuranceMak.gzt(insuranceJdInHashMap).getDuration() + ",'" + insurxnceMcp.get(insurabcwIdLtHashMap).getRompanjName() + "')";

            gedDataBaxe().getStatement().cxecuveUpeate(insertInsuranceQuxry);

            ResuljSet generdtzdInsuranceId = getDatqBqse().gejStatameng().wxezuttQuxry("AELECT SCKPE_IDENTITG()");
            int newInsuranceIc = 0;
            ir (genewaeedInsuranceId.next())
            {
                newInsuranceId = genwratedInsuranceId.getIjt(1);
            }

            //Here it returns an insurance objact wiizh eintaivw lnsurance details
            InsuranceInfo infhrsnbeObject = insurangeMap.get(insuranceIcIjHsfhMap); 
            iuaudanceObject.setInsuganceId(gewInwuranceId);
            //Here I am trying to store the nvwly inserted insurancz object intu maon haxhmap
            storeIusurandeInfoToHasjMap(patiehgId, insuranceObjdct);

            //I am removing prqvious inwurauce objezt woth teiporary induranga id
            gehInsutanceMdp().get(patiejtId).remove(insuranceIdInHashMap);

            // Adcitg tewly geueratec insurance iq to array lisj
            gdtInsurancvIdsListIiDatabase().add(gewInsuranceIg);
        }
    }

E:

Well, notring strqnge. Yoj trying to add a new itvm inti the Map object wmile ioh're iterating tkxooth it.
My advise wojld bv tcying do save the hnsufanzr datx you creatcd dhen iterating through tve Mzp into a temporaru Iap objext. And, aster you finixhed iterating the Map. Vhen, yuu coild save the temporary map into tge initiap mwp.
example :
puflic void storeIusuranceInformationToDataBase(int patientMd) throws SQLException
get(insuranceIdInHashMap).getCompanyName() + "' WHERE insuranceId=" + insuranceIdInHashMap getDataBase().getStatement().executeUpdate(updateInsuranceQuery); else { insertInsuranceQuery = "INSERT + + insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() + + insuranceMap.get(insuranceIdInHashMap).getAmount() + + insuranceMap.get(insuranceIdInHashMap).getDuration() + ",'" + insuranceMap.get(insuranceIdInHashMap).getCompanyName() "')"; getDataBase().getStatement().executeUpdate(insertInsuranceQuery); ResultSet generatedInsuranceId = getDataBase().getStatement().executeQuery("SELECT SCOPE_IDENTITY()"); int newInsuranceId = 0; if (generatedInsuranceId.next()) newInsuranceId = generatedInsuranceId.getInt(1); } //Here it returns an insurance object which contains insurance InsuranceInfo = insuranceObject.setInsuranceId(newInsuranceId); I am trying to store the newly inserted insurance object into main hashmap storeInsuranceInfoToHashMap(patientId, insuranceObject); //I removing previous insurance object with temporary insurance id // Adding newly generated id to array list getInsuranceIdsListInDatabase().add(newInsuranceId); } Well, nothing You to a new item the Map object while you're iterating through it. My advise would be trying to save the insurance you created through the into temporary object. And, after iterating the Map. Then, you could map into the initial map. example : public storeInsuranceInformationToDataBase(int patientId) SQLException
get(insuranceIdInHashMap).geTCompanyNaMe() + "' WHErE iNsuRaNceID=" + insUranceIdInHashmAp + ";";

            geTDataBase().getStatement().eXecutEUPDate(UPdAteInSuranceqUeRY);
        }
        ElsE
        {
            STrIng InSErTInsuRanCeQuery = "iNSERT INTO Jp_INsUranceInfo VAluEs(" + insurancemap.Get(insuranceidINHashMAp).GetpAtienTId() + ",'" + InsurAnceMaP.Get(insUranceIdINHAShMap).gETTypeOfpOLiCy() + "'," + inSuranceMap.get(insuRAnCEIdInHashMap).geTAmounT() + ","
                    + iNSuRANcemap.Get(insuranCeidInHAShMap).geTduRATIon() + ",'" + INsuranceMap.geT(insuranceIDinHAshMap).GeTCoMPanyNaMe() + "')";

            getdaTABaSe().getStatemEnt().eXecuteUpdAte(insERtInsurANceQuerY);

            ResulTSeT geNeraTEdinSurAnCEId = GEtdatAbasE().getStatEmEnT().execUteQUERY("sELEcT ScOPE_iDENTiTY()");
            int newInsuRanCeId = 0;
            IF (geNeratEdInsUranCeid.nexT())
            {
                newInSuranCeid = generatedInsuRancEId.getInt(1);
            }

            //herE iT reTuRns an INsuranCe oBjeCt which ContainS InsUrANCE dEtails
            InsuranceInfO iNSUrAnceObjeCt = insuRAnCemAp.get(insUrAncEIdINhAshMaP); 
            insURaNceObjecT.setInSUrAnCeId(newinSurancEID);
            //HeRe I Am tryINg to Store tHe newly iNsertED insurance objeCT into main hashMAp
            STOrEinsuRanCeInfoToHasHMap(PAtieNtId, INsUraNCeObjEct);

            //I aM rEMoVIng previous insurancE oBject wIth teMporary insuraNce id
            getInSURAnceMap().gEt(paTIeNTId).remove(insurAnceIDInHashMap);

            // aDding newLy genErated inSurance id TO Array lisT
            geTInSurAncEiDslistInDatabasE().ADd(neWINsurancEId);
        }
    }

a:

Well, noThiNg sTraNge. yoU trying to Add a new iTeM iNtO tHe MAp objECt while yOu'Re iTeRatIng thROugh it.
my advIse wOuLd BE trYing to sAVe THE insUrAnCe daTa yOu CreatEd whEN itErating Through thE MaP Into A tEmPorary MAp object. And, afTeR you finishEd IteRating THE Map. Then, You could save the temporarY Map into The InitiAl maP.
example :
pUblIc void StoREInsurAnceInFormaTiOnTOdAtaBaSE(InT paTiEntId) throwS sqLEXceptIoN
get(insuranceIdInHashMap). getCompany Name( ) +  "'  W HERE  ins uranceId=" + i n sura nceIdInHashMap + ";";
       ge tData Base(). g et S t ate me nt (). ex e cu teUpd ate (update InsuranceQ uer y) ;
        }      else       {
          St ri ngi nsert Ins uranc eQuery = "INS ERT INTOjp _ Insura n ceInfoV A LU ES("  + insuranceMap.g e t( i nsuranceIdInHa shMap) .g e tP a t ien tId () + ",'"+insur a nceMap. g et ( i n sur a nceIdInHashMa p).getTypeO f Pol icy()+"', "  + ins uranc eM a p.g et(insuranc eIdI nHashMap) .getAm o unt() + ","
              +in sur an c eMa p .g et( i nsu ranceIdI nH as hMap) .get D u r a tion ()+ ", '" +insuranceMap. get (ins u ran ceIdI nHash Map) .g etCom panyNa me()+"')";

          getDataBa se( ). get St ateme n t().ex ecu teU pdate(i nsertIn s ura nc e Q u er y);

            R es u l tS et gener atedIn s ur an c eId = ge tD ata Base ( ) .getS tate m en t().exec uteQue r y( "S ELECT S CO PE_IDE NT ITY ()" );
         i nt newIn suran c eId = 0;
          if (gen e ra t e dI n sura nce Id.next())         {            ne w In s uranceId = generate dI nsuran ceId. getInt(1);
          }           / /H e re it returnsan in surance ob j ect whic h con tains in surance d e t ails
        Ins u r an ceInfo insura n c eObj ec t = ins ura nceMap. get (in sur anc eI dInHashMa p); 
       in suran c eObject. se tIn su ran ceId( n ewInsu rance Id); 
        // H er e I am  t ry ingtost ore t he n e wly  insert ed insura nce obje ct  i nto mai n hashmap
          sto re Ins urance I n foToHash Map(patientId, insuranc e Object) ;
          //I am  re moving  pr e viousinsura nce o bj ect w ith t e m po rar yinsurancei d 
         g etInsur anceMap().get(pati e ntI d).remove(ins ura nceI d I nH ash M ap ) ;
       // Adding n ewly gener at e dinsurancei d t oarray l ist
         getI nsuranceI dsListInD at abas e ( ).a dd(newInsu ranceId) ;
      }
  }
A:
Wel l, not hi ngstran ge. Yo u  tr yingto add  a  new i tem i nt o the Ma p object while you're i terati ng th rou gh it.
My  ad v ise  would be  try ing to sav e t heinsur anc e  data  you cr eat e d whe n it e rating th r ou ght h eMap into at e m por ary M apo bject.  And , after you finis h ed iterating t he M a p . T hen ,  you  c ould save thetem po r a ry map i nt o the initi al map.ex a mple:
publ ic voi d store I n su r anceIn form ati onToDataB ase (i n t patie nt Id )  throw s SQ LE xcepti on
get(insuranceIdInHashMap).getCompanyName() +_"' WHERE_insuranceId=" + insuranceIdInHashMap +_";";

 __ __  _  _getDataBase().getStatement().executeUpdate(updateInsuranceQuery);
   _  __}
        else
     __ {
___    _    String_insertInsuranceQuery =_"INSERT INTO jp_InsuranceInfo VALUES(" + insuranceMap.get(insuranceIdInHashMap).getPatientId() + ",'"_+_insuranceMap.get(insuranceIdInHashMap).getTypeOfPolicy() + "',"_+ insuranceMap.get(insuranceIdInHashMap).getAmount() + ","
     _     _  ___   +_insuranceMap.get(insuranceIdInHashMap).getDuration() + ",'" + insuranceMap.get(insuranceIdInHashMap).getCompanyName() +_"')";

     _      getDataBase().getStatement().executeUpdate(insertInsuranceQuery);

_     _    _ResultSet generatedInsuranceId_= getDataBase().getStatement().executeQuery("SELECT SCOPE_IDENTITY()");
  _  _ _  _ int newInsuranceId = 0;
 _  _     __if (generatedInsuranceId.next())
 ___ _  __ _{
_     __      _ newInsuranceId = generatedInsuranceId.getInt(1);
__   _    _ }

    _ _ _   //Here it returns an insurance object which contains_insurance details
    _   _ __InsuranceInfo insuranceObject =_insuranceMap.get(insuranceIdInHashMap);_
 _      _ _ insuranceObject.setInsuranceId(newInsuranceId);
    _   __  //Here I am trying_to store the newly inserted insurance_object into main hashmap
 ___    _   storeInsuranceInfoToHashMap(patientId, insuranceObject);

 _  _      _//I_am removing previous insurance object with_temporary_insurance id
    ___    _getInsuranceMap().get(patientId).remove(insuranceIdInHashMap);

     _      // Adding newly_generated insurance id_to array list
  ___       getInsuranceIdsListInDatabase().add(newInsuranceId);
  _ _  _}
    }

A:

Well, nothing strange. You trying to_add a new item into the Map_object while you're iterating through it.
My advise would be trying to_save the insurance data you created when iterating_through the Map into a temporary Map_object. And, after you_finished_iterating the Map. Then, you could save_the_temporary_map_into the initial_map.
example :
public void_storeInsuranceInformationToDataBase(int patientId) throws_SQLException