0
点赞
收藏
分享

微信扫一扫

[GKCTF 2021]签到

月半小夜曲_ 2024-12-02 阅读 8

问题描述:
使用Mybatis-plus插入用户数据报错
在这里插入图片描述
错误:

SQL: INSERT INTO t_user ( id, username, pwd ) VALUES ( ?, ?, ? )

Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column ‘id’ at row 1; Data truncation: Out of range value for column ‘id’ at row 1; nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Out of range value for column ‘id’ at row 1

分析原因:
自增Id未写入占位符,导致参数不匹配

解决方法:加入注解
@TableId(type = IdType.AUTO) 是 MyBatis-Plus 用于标识数据库表主键字段的注解。其中 IdType.AUTO 表示数据库表的主键字段采用自增策略,由数据库自动生成主键值。如果手动设置主键 id 值后插入数据库,值仍然会按自增插入,不会按设置的值插入。
在这里插入图片描述

举报

相关推荐

0 条评论