preparedStatement.setObject报错

java.sql.BatchUpdateException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'xx'
通常是preparedStatement.setObject(index,obj);
其中 obj 是自定义的数据类型(非Integer,String等)导致。

问题场景:
setObject(index,obj) 打印obj结果是null,始终想不明白为啥会报错(以为是null)
使用强转String,发现该obj为net.sf.json.JSONNull类型。。。
解决:
if(JSONNull.getInstance().equals(value)) {
ps.setObject(i, null);
}

posted @ 2021-09-23 13:56  赵钱富贵  阅读(419)  评论(0编辑  收藏  举报