### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'xxxxxx@163.com' for key 'AK_idx_email'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into user( name, phone, email, aboutme, passwd, avatar, type, create_time, enable )values( ?, ?, ?, ?, ?, ?, ?, ?, ? );
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'xxxxxx@163.com' for key 'AK_idx_email'
; SQL []; Duplicate entry 'xxxxxx@163.com' for key 'AK_idx_email'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '18201041175@163.com' for key 'AK_idx_email'
小编的用户表中,给email设置的是唯一索引。
在数据库中报错sql的错,仔细思考,由于自己设置的email是唯一索引,在数据库中就不能添加第二个,所以报错。
索引如果是primary unique这两两种,那么数据表的数据对应的这个字段就必须保证其每条记录的唯一性。否则就会产生这个错误。