当前位置:   article > 正文

ShardingSphere修改报错-MysqlDataTruncation: Data truncation: Out of range value for column ‘xx‘ at row 1_com.mysql.cj.jdbc.exceptions.mysqldatatruncation:

com.mysql.cj.jdbc.exceptions.mysqldatatruncation: data truncation: out of ra


一、场景

1、项目使用ShardingJDBC操作数据库

2、修改SQL执行报错


二、报错信息

### Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
### The error may involve com.xxx.mapper.service.KeyWordMapper.updateByExample-Inline
### The error occurred while setting parameters
### SQL: UPDATE t_wx_keyword  SET keyword = ?,msgType = ?,msgId = ?,content = ?,createTime = ?,eable = ?,matchType = ?,originId = ?,vdnId = ? WHERE (       (  vdnId = ?                                                and originId = ?                                                and id = ? ) )
### Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
; Data truncation: Out of range value for column 'MSGID' at row 1; nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
org.springframework.dao.DataIntegrityViolationException: 
### Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
### The error may involve com.xxx.mapper.service.KeyWordMapper.updateByExample-Inline
### The error occurred while setting parameters
### SQL: UPDATE t_wx_keyword  SET keyword = ?,msgType = ?,msgId = ?,content = ?,createTime = ?,eable = ?,matchType = ?,originId = ?,vdnId = ? WHERE (       (  vdnId = ?                                                and originId = ?                                                and id = ? ) )
### Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
; Data truncation: Out of range value for column 'MSGID' at row 1; nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column 'MSGID' at row 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

三、原因

表字段的数据类型与实体类属性的类型不一致

在本例中:表字段MSGID的数据类型是int,而实体类的msgId属性类型是String,类型不一致


四、解决

方法1、更改表字段数据类型,与实体类属性类型一致

方法2、更改实体类属性类型,与表字段数据类型一致

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/659131
推荐阅读
相关标签
  

闽ICP备14008679号