java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件

时间:2020-02-27 11:48:21   收藏:0   阅读:343

Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (JDDS.PK_SHOP_MESSAGE)
### The error may involve com.shop.dao.itf.MessageMapper.insert-Inline
### The error occurred while setting parameters
### SQL: insert into SHOP_MESSAGE (MESSAGE_ID)  values (?)
### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (JDDS.PK_SHOP_MESSAGE)
; SQL []; ORA-00001: 违反唯一约束条件 (JDDS.PK_SHOP_MESSAGE)
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (JDDS.PK_SHOP_MESSAGE)

 

因为表中主键字段一般都设置了唯一约束条件,插入时与已有数据主键字段相同时就会产生错误信息。

解决方法:主键的内容不要设置太简单,比如可以用MD5加密后的字符串,,加入时间和其他一些独有信息生成主键更不容易重复哦!

原文:https://www.cnblogs.com/name-lizonglin/p/12370734.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!