| Author |
Avoid Duplicate entries in MySQL table
|
Tarik Ansari
Ranch Hand
Joined: Dec 31, 2008
Posts: 40
|
|
HEllo, Please tell me how to chk for Duplicate entry message in JDBC Update query. Eg:if i have a mobile no in a table it shud not allow me to enter the same number,instead it shud give a message "Mob no already exists" thanks Tarik Ansari [edited out e-mail - Please use the forum not e-mail] [ December 31, 2008: Message edited by: Tarik Ansari ] [ December 31, 2008: Message edited by: Jeanne Boyarsky ]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
Welcome to JavaRanch You could try searching for the mobile number in the database before inserting, but it is probably better to use the UNIQUE keyword in the SQL. You will get a straightforward SQLException with error state, error code, and message.
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
If possible add the UNIQUE keyword to the table's definition for that column.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
 |
|
|
subject: Avoid Duplicate entries in MySQL table
|
|
|