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

强颜欢笑 提交于 2020-02-27 11:00:07

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加密后的字符串,,加入时间和其他一些独有信息生成主键更不容易重复哦!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!