1.情况限制

  此处的错误解决方案只讨论:

    在使用Mybatis时,传入数组且使用<foreach>标签时出现此种报错;

  2.报错案例

   mapper.java

    /**
* @Description: 取消验厂通知
* SupplierCheckfactoryInformMapper
* cancelNotifyToCheckFac
* @param params
* 2016-8-24 下午3:42:44
*/
public void cancelNotifyToCheckFac(
          @Param("regId")Integer regId,
          @Param("updateDt")Date updateDt,
          @Param("supplierIds")BigInteger[] supplierIds
         );

    mapper.xml

<update id="cancelNotifyToCheckFac">
UPDATE
t_supplier_regaccount_info tsri,
t_supplier_checkfactory_inform tsci
SET
status = 2,
update_dt = #{updateDt}
WHERE
tsri.supplier_id = tsci.supplier_id
AND
tsri.supplier_id in
<foreach collection="supplierIds" item="item" index="index" open="(" separator="," close=")">
#{supplierIds}
</foreach>
AND
tsri.reg_id = #{regId}
AND
tsci.status = 0
</update>

    报错信息:

### Error updating database.  Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '\xAC\xED\x00\x05ur\x00\x17[Ljava.math.BigInteger;\x0E|\xDBF\xE0:`\xC6\x02\x00\x00xp\x00\x00\x00\x01sr\x00\x14java.math.BigIntege'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: UPDATE t_supplier_regaccount_info tsri, t_supplier_checkfactory_inform tsci SET status = 2, update_dt = ? WHERE tsri.supplier_id = tsci.supplier_id AND tsri.supplier_id in ( ? ) AND tsri.reg_id = ? AND tsci.status = 0
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '\xAC\xED\x00\x05ur\x00\x17[Ljava.math.BigInteger;\x0E|\xDBF\xE0:`\xC6\x02\x00\x00xp\x00\x00\x00\x01sr\x00\x14java.math.BigIntege'
; SQL []; Data truncation: Truncated incorrect DOUBLE value: '\xAC\xED\x00\x05ur\x00\x17[Ljava.math.BigInteger;\x0E|\xDBF\xE0:`\xC6\x02\x00\x00xp\x00\x00\x00\x01sr\x00\x14java.math.BigIntege'; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '\xAC\xED\x00\x05ur\x00\x17[Ljava.math.BigInteger;\x0E|\xDBF\xE0:`\xC6\x02\x00\x00xp\x00\x00\x00\x01sr\x00\x14java.math.BigIntege'
ERROR 2016-09-18 15:03:17,661 util.web.ExceptionAdvisor: 内部/外部请求人:/admin
ERROR 2016-09-18 15:03:17,661 util.web.ExceptionAdvisor: 请求IP:0:0:0:0:0:0:0:1
ERROR 2016-09-18 15:03:17,662 util.web.ExceptionAdvisor: 请求参数:{supplierId=26};
ERROR 2016-09-18 15:03:17,662 util.web.ExceptionAdvisor: =====service通知结束,继续向上抛BusinessException=====
WARN 2016-09-18 15:03:17,669 org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver: Handler execution resulted in exception
common.model.BusinessException: 抱歉,程序内部错误,操作失败! 请稍后再试或与管理员联系!

    3.错误分析

    此处的报错信息:Data truncation: Truncated incorrect DOUBLE value

      3.1:在网上的主要错误原因是:update语句中的set中出现了and关键字,而应该使用逗号<,>代替之;这里的报错不属于这种情况;

      3.2:此处错误原因为:<foreach>标签中不能使用参数名#{supplierIds},而应该使用#{item},貌似为固定写法;根本原因尚不明确,待大神指点;

    

    4.代码修改后

    mapper.xml

<update id="cancelNotifyToCheckFac">
UPDATE
t_supplier_regaccount_info tsri,
t_supplier_checkfactory_inform tsci
SET
status = 2,
update_dt = #{updateDt}
WHERE
tsri.supplier_id = tsci.supplier_id
AND
tsri.supplier_id in
<foreach collection="supplierIds" item="item" index="index" open="(" separator="," close=")">
#{item} <-- *此处为错误原因* -->
</foreach>
AND
tsri.reg_id = #{regId}
AND
tsci.status = 0
</update>

  其他的代码不做修改;

    5.结果

    修改后,可正常更新记录,不再报错;

Data truncation: Truncated incorrect DOUBLE value 解决方案的更多相关文章

  1. Data truncation: Truncated incorrect DOUBLE value错误的解决方案

    Data truncation: Truncated incorrect DOUBLE value错误的解决方案: 当在修改某条单位记录时,发生了Data truncation: Truncated ...

  2. Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: &#39;L

    1.错误叙述性说明 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error execut ...

  3. Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'L

    1.错误描述 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error executing ...

  4. Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'as3'

    执行更新时的出错信息 Whitelabel Error Page This application has no explicit mapping for /error, so you are see ...

  5. com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value:...

    在使用mybatis的@Update注解的时候,报了一个这样的错 ### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncat ...

  6. Data truncation: Truncated incorrect DOUBLE value:

    在写sql查询语句queryRunner.update(connection,"update account set balance=? where name=?",account ...

  7. java.sql.SQLException: Data truncation: Truncated incorrect DOUBLE value

    mysql 报这个异常:java.sql.SQLException: Data truncation: Truncated incorrect DOUBLE value update 表名 set c ...

  8. 异常-Data truncation: Truncated incorrect DOUBLE value: '-9370.3530-'

    1详细异常日志 9/11/04 17:36:09 ERROR base.SQLHelper: Data truncation: Truncated incorrect DOUBLE value: '- ...

  9. Mysql [Err] 1292 - Truncated incorrect DOUBLE value: 'a'

    报错信息: [SQL] UPDATE 表 set times = 1 where type = 1 and times = 0 [Err] 1292 - Truncated incorrect DOU ...

随机推荐

  1. PHP删除MySQL数据库下的所有数据表

    <?php //[数据无价,请谨慎操作!] $hostname ='localhost';  $userid = 'username';  $password = 'password';  $d ...

  2. sql必知必会(第四版) 学习笔记

    还有一个<Sqlserver2008技术内幕>的笔记,也很好!~ http://www.cnblogs.com/liupeng61624/p/4354983.html 温习一遍简单的sql ...

  3. setw和setfill控制输出间隔

    在C++中,setw(int n)用来控制输出间隔.例如:cout<<'s'<<setw(8)<<'a'<<endl;则在屏幕显示s a //s与a之间 ...

  4. LA 3907 Puzzle

    问题描述:先给你s个禁止串,求不包含禁止串的最长串,如果存在,打印字典序最大. 数据范围:s <= 1000, 禁止串长度不超过50. 分析:不匹配问题实际上等同于匹配问题.假设我们已经有满足条 ...

  5. Squares 分类: POJ 2015-08-04 11:46 3人阅读 评论(0) 收藏

    Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 17462 Accepted: 6634 Description ...

  6. Case of the Zeros and Ones 分类: CF 2015-07-24 11:05 15人阅读 评论(0) 收藏

    A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...

  7. 排序练习——找出前m大的数字 分类: 排序 2015-06-08 09:33 21人阅读 评论(0) 收藏

    排序练习--找出前m大的数字 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 给定n个数字,找出前m大的数字.   输入  多组输 ...

  8. C#微信开发文档

    C#微信开发文档 开发前准备 微信公众平台链接: https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN 开发初期我们使用测 ...

  9. linux内核中创建线程方法

    1.头文件 #include <linux/sched.h> //wake_up_process() #include <linux/kthread.h> //kthread_ ...

  10. hdu 4961 Boring Sum

    Boring Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tota ...