mybatis 中insert语句报如下错误: Incorrect integer value: '' for column 'pic_len' at row 1
2015-12-24 11:43
543 查看
使用mybatis插入数据:
1)数据库表结构中pic_len是一个int(2)类型的字段;
2)springmvc的controller从前端表单获取到pic_len表单项数据pLen,加入前端表单未输入值,这时pLen输出为空字符串“”;
3)使用mybatis插入数据 insert into ....pic_len=#{pLen},... 这时,就会报错:Incorrect integer value: '' for column 'pic_len' at row 1
解决办法:网上说是mysql5版本问题,需要修改sql_mode,将其修改为sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION",但我尝试后仍然有问题。索性,使用下面方法解决:
在mybatis中,传值的时候把“”改成了null:
paramMap.put("picLen", null);
1)数据库表结构中pic_len是一个int(2)类型的字段;
2)springmvc的controller从前端表单获取到pic_len表单项数据pLen,加入前端表单未输入值,这时pLen输出为空字符串“”;
3)使用mybatis插入数据 insert into ....pic_len=#{pLen},... 这时,就会报错:Incorrect integer value: '' for column 'pic_len' at row 1
解决办法:网上说是mysql5版本问题,需要修改sql_mode,将其修改为sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION",但我尝试后仍然有问题。索性,使用下面方法解决:
在mybatis中,传值的时候把“”改成了null:
paramMap.put("picLen", null);
相关文章推荐
- UILabel上的文字 单独改变 属性
- 分割视图控制器(UISplitViewController)
- PHP 性能分析第二篇: Xhgui In-Depth
- UITableViewController和UIRefreshControl实现下拉刷新功能
- ueditor使用会于第三方发生冲突
- UIScrollView中contentSize、contentInset、contentOffset介绍
- 解决The current branch is not configured for pull No value for key branch.master.merge found in confi
- CoreBluetooth框架(转)
- UILabel
- String,StringBuffer与StringBuilder的区别
- iOS 教你学UI控件的封装
- PHP 性能分析第一篇: Intro to Xhprof & Xhgui
- 法院执行人信息 业务 使用了多线程 cookie BlockingQueue 的一本程序
- Rails 多态关联 :polymorphic => true
- proguardgui.bat来混淆已有的jar包
- 如何在 Ubuntu 中安装最新的 Arduino IDE 1.6.6
- 自定义Label文字绘制区域
- NGUI
- requireJS的使用
- 改变 UITextField 提示语的 字体颜色