I have question to avoid Duplicate field in Database while using JSP and Servlet. Because when i am inserting product it can duplicate. So if anyone can add the duplicate value it shows Item/product already available. So i need to know how is that possible to perform the task.
Asked
Active
Viewed 221 times
-2
-
2set the UNIQUE constraint in the database – Aleksei Maide Jan 26 '18 at 07:08
-
2Or insert using a `WHERE NOT EXISTS` clause. – Tim Biegeleisen Jan 26 '18 at 07:08
-
Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) before attempting to ask more questions. – Jan 26 '18 at 07:22
-
Please read [What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask) before attempting to ask more questions. – Jan 26 '18 at 07:22
1 Answers
-2
Use unique key constraint,If you can't make the primary key, the only way to prevent inserting it again, is doing a select first. https://www.daniweb.com/programming/databases/threads/279923/check-for-duplicates-before-insert

Sreejesh K Nair
- 563
- 1
- 6
- 16
-
Please read [How do I write a good answer?](http://stackoverflow.com/help/how-to-answer) before attempting to answer more questions. – Jan 26 '18 at 07:20