Hi,
I am getting the data from the CSV file and inserting it to the database. Now while inserting I have to check that some of the data(to be inserted) is already existing in the table or not. If existing then I have to overwrite that data. Now here is what I have done :--
My table has some fields like Id(primary key), name, and imported_date. Now what I am doing is I am comparing all the Ids(in the table) and Ids(in the CSV file. like this:-
This logic is working fine. But I want to know Is there any other more optimize way to do that. Because as the records will increase in the table this section(code) could decrease the code performance.
I am getting the data from the CSV file and inserting it to the database. Now while inserting I have to check that some of the data(to be inserted) is already existing in the table or not. If existing then I have to overwrite that data. Now here is what I have done :--
My table has some fields like Id(primary key), name, and imported_date. Now what I am doing is I am comparing all the Ids(in the table) and Ids(in the CSV file. like this:-
Code:
rs = pStatement.executeQuery(); while(rs.next()) { for(int i = 0; i < v.size(); i++) { if(((DefectDetailVO)v.get(i)).getDefectId().equals(rs.getString("DEFECT_ID"))) { System.out.println("Is Record Updated::: " +updateExistingDefectDetails((DefectDetailVO)v.get(i))); v.removeElementAt(i);//Here v is a vector and consists records coming from CSV file break; } } }
Comment