ShardingSphere修改报错-MysqlDataTruncation: Data truncation: Out of range value for column ‘xx‘ at row 1
短信预约 -IT技能 免费直播动态提醒
一、场景
项目使用ShardingJDBC操作数据库
修改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 1org.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
三、原因
表字段的数据类型与实体类属性的类型不一致
在本例中:表字段MSGID的数据类型是int
,而实体类的msgId属性类型是String
,类型不一致
四、解决
方法1、更改表字段数据类型,与实体类属性类型一致
方法2、更改实体类属性类型,与表字段数据类型一致
来源地址:https://blog.csdn.net/weixin_52116015/article/details/130739559
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341