MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value

来源:互联网 发布:phpcms和帝国cms 编辑:程序博客网 时间:2024/05/16 07:15

org.apache.ibatis.exceptions.PersistenceException:
###Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘Putin’
The error may involve test.updateUser-Inline
The error occurred while setting parameters
SQL: update user set username = ? and address = ? where id = ?
Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘Putin’
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:154)
at mybatis01_start.Mybatis01.UpdateUser(Mybatis01.java:80)
···25 more

来来回回瞅了半天,原来是sql语句错了

update user set username = #{username} and address = #{address} where id = #{id}

把 and 改成 逗号 , OK
update user set username = #{username} , address = #{address} where id = #{id}

低级错误!!!sql语法错误
update语句,如果有更多的列,就用逗号连接,不是and

update 表名 set 字段名1 = 值1 , 字段名2 = 值2 , …. , 字段名n = 值n where 条件

注意:如果没有where条件,会将所有记录修改;

注意避免sql语句的语法错误,还是要习惯性地先在Navicat运行测试一下。。。

阅读全文
0 0