Im working on reading a .xls file (excel) and inserting it to my database. Im using a jsp to do this and it's working fine if there's no duplicate key.
patientId = list1.get(i).toString();
patientFname = list2.get(i).toString();
patientLname = list3.get(i).toString();
patientMname = list4.get(i).toString();
patientGender = list5.get(i).toString();
patientBirthday = list6.get(i).toString();
patientAge = list7.get(i).toString();
patientAddress = list8.get(i).toString();
patientCompany = list9.get(i).toString();
ResultSet rs=st.executeQuery("SELECT idpatients FROM patients");
if (rs.first()) {
}
st.executeUpdate("insert into patients(idpatients,pfirstname,plastname,pmiddlename,gender,birthdate,age,address,company) values('"+patientId+"','"+patientFname+"','"+patientLname+"','"+patientMname+"','"+patientGender+"','"+patientBirthday+"','"+patientAge+"','"+patientAddress+"','"+patientCompany+"')");
It's not working if there's a duplicate primary key and I would like to ignore that and proceed to the next data.