博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: java.sql.SQLInt
阅读量:3945 次
发布时间:2019-05-24

本文共 292 字,大约阅读时间需要 1 分钟。

一 报错信息

org.springframework.dao.DuplicateKeyException:
Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘hm’ for key ‘username’
二 分析原因
因为表中主键字段一般都设置了唯一约束条件,插入时与已有数据主键字段相同时就会产生错误信息。
三 解决办法
主键的内容不要设置太简单,比如可以用MD5加密后的字符串,,加入时间和其他一些独有信息生成主键更不容易重复哦!

转载地址:http://nalwi.baihongyu.com/

你可能感兴趣的文章
Using the Support Library
查看>>
Creating a Fragment
查看>>
Building a Flexible UI
查看>>
Communicating with Other Fragments
查看>>
Saving Key-Value Sets
查看>>
Saving Files
查看>>
Saving Data in SQL Databases
查看>>
Sending the User to Another App
查看>>
Getting a Result from an Activity
查看>>
Allowing Other Apps to Start Your Activity
查看>>
Using the Location Manager
查看>>
Obtaining the Current Location
查看>>
Displaying the Location Address
查看>>
Connecting to the Network
查看>>
Managing Network Usage
查看>>
Parsing XML Data
查看>>
Optimizing Downloads for Efficient Network Access
查看>>
Minimizing the Effect of Regular Updates
查看>>
Redundant Downloads are Redundant
查看>>
Modifying your Download Patterns Based on the Connectivity Type
查看>>