MySQL Forums
Forum List  »  General

duplicate entry for key
Posted by: abhi mahajan
Date: July 24, 2010 07:14AM

hi 2 every1,

i created a table 'empp' with 4 fields starting with 'eid', 'uname', 'password', 'first_name'. i made 'eid' as auto-increment nd assigned primary key to it. 'uname' is set as unique nd first_name is set as default.
nw i made a java swing application with jdbc incorporated in it. i tried to insert values through java application nd i m facing two problems. the insert command is as follows:

"insert into empp (uname,password,first_name) values ('lambda','hello','abhi')";

notice that i skipped the eid column as it is auto incremented. so the problems:

1. after filling the entries in java application and after successful entry in table, i get an exception message after closing application as:
"exception occurs : duplicate entry 'lambda' for key 2"
this whole entry is successfully inserted into table. so what is the meaning of 'duplicate entry' nd why is it happening??

2. suppose i inserted a row in table through application, after successful entry in table i get an new eid as 106 (say), means that last entry of table had eid content as 105. nw if i delete this account i.e. with eid as 106 and then re-enter new values in table, i get the new eid as 107 instead of 106 which ws deleted previously. why is this happening nd what could be done to avoid this??

thanx in advance

Options: ReplyQuote


Subject
Written By
Posted
duplicate entry for key
July 24, 2010 07:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.