使用jdbcTemplate时遇到一个报错信息:

Truncated incorrect DOUBLE value

查了一下网上的资料,发现原来是把sql语句中的 逗号 写成了 and
改回逗号后,成功运行!

更改前:

@Override
public int updateUser(String name,String pwd, int id) {
	return jdbcTemplate.update("update mybatis.user set name=? and pwd=? where id=?",name,pwd,id);
    }

更改后:
在这里插入图片描述
实在是太不应该了。。。。。

网上搜索到的对“Truncated incorrect DOUBLE value”的解决方法主要是这两种:
① 修改了多个列的值而各列之间用逗号连接而不要用 and
错误写法示例:update user set col1=value1 and col2=value2 where col3=value3;
正确写法示例:update user set col1=value1 ,col2=value2 where col3=value3;
② SQL语句在拼接字符串时使用函数CONCAT()而不要用“+”
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐