Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [update account set
money = money - ? where username = ?]; Data truncation: Truncated incorrect DOUBLE value: 'xxx'; nested exception is com.mysql
.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'xxx'
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:102)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:82)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:82)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:655)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:937)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:947)
at org.cwj.Dao.Imp.AccountDaoImp.out(AccountDaoImp.java:29)
at org.cwj.Service.Imp.AccountServiceImp.trand(AccountServiceImp.java:33)
at org.cwj.Text.Text.main(Text.java:29)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'xxx'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4230)
3 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [update account set money = money - ? where username = ?]
看下这个SQL 的参数 money 传入的值的长度跟数据库类型的长度肯定不一致导致了入库截断异常了。
紫衣仙女
TA贡献1839条经验 获得超15个赞
update account set money = money - ? where username = ?
应该是这一句传入的数据长度不对,有可能是你传入的数据类型是double,但是数据库设定的numeric长度不够,可以设置断点或者打印出来看一下
添加回答
举报
0/150
提交
取消