I’m inserting a record in oracle database, where I’m taking values from a java bean. It goes like this::
insert into allergy (patient_id, allergy, reaction) values(seq_patient.nextval, '" + bean.getPatient_allergy() + "', '"+ bean.getReaction()+"')";
But the values for allergy can gave an apostrophe which causes the sql to fail with ORA-00917: missing comma. is there any way to overcome this problem?
Use parameterized statements instead of injecting variables into a query:
http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html