新增异常\r\n### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstrain

错误完整提示:

"新增异常\r\n### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '23434375573' for key 'PRIMARY'\r\n### The error may exist in file [C:\\Users\\xxxx\\xxxxx\\xxxx\\xxxx\\target\\classes\\mapper\\InsertMapMapper.xml]\r\n### The error may involve com.xxxx.dao.InsertMapMapper.insertInfo2-Inline\r\n### The error occurred while setting parameters\r\n### SQL: insert into WUXING_WARN_STATION_WATER_LEVEL          (               ID          ,              STWARNID          ,              STCD          ,              STNM          ,              LONGITUDE          ,              LATITUDE          ,              ORIGINALADCD          ,              ORIGINALADNM          ,              STWARNSTM          ,              STWARNETM          ,              STWARNNM          ,              STWARNDESC          ,              FLOODLIMITWL          ,              NOWWL          ,              ADCD          ,              TONG_TIME          ,              OP          ,              REMARK          )          values                         (                   ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              )                         , (                   ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              )                         , (                   ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              ,                  ?              )\r\n### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '23434375573' for key 'PRIMARY'\n; Duplicate entry '23434375573' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '23434375573' for key 'PRIMARY'",

在往表里插入数据的时候,报了个错,原因是数据表中设置了主键(Primary Key),而主键对应的值是不允许重复的,我在插入的时候重复了“23434375573”这个值,所以报错。只要在每次插入的时候,保证这个主键唯一就行了。

 

 

 

 

 

你可能感兴趣的:(BUG)