您的位置:首页 > 产品设计 > UI/UE

MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value

2017-10-22 10:51 543 查看
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运行测试一下。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐