sql插入数据报错 code 1465

具体报错信息如下:
09:41:02.016 [374010909@qtp-497872115-7] ERROR c.c.ibs.action.SyncCommonTrsAction - 入库出错:SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [72000]; error code [1465];
— The error occurred in META-INF/config/sql-mapping/qrdcar.xml.
— The error occurred while applying a parameter map.
— Check the qrdcar.insertSendDataInfo-InlineParameterMap.
— Check the statement (update failed).
— Cause: java.sql.SQLException: ORA-01465: 无效的十六进制数字
; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
— The error occurred in META-INF/config/sql-mapping/qrdcar.xml.
— The error occurred while applying a parameter map.
— Check the qrdcar.insertSendDataInfo-InlineParameterMap.
— Check the statement (update failed).
— Cause: java.sql.SQLException: ORA-01465: 无效的十六进制数字

代码程序
this.getSqlMap().insert(“qrdcar.insertSendDataInfo”, buildInsertMap(context));

private Map **buildInsertMap(Context context)** {
	Map insertMap = new HashMap();
	insertMap.put(Constants.JNL_NO, context.getData(Constants.JNL_NO));
	insertMap.put("BackstageTransCode", context.getData("TranId"));
	insertMap.put("RequestTime", new Date());
	insertMap.put("RequestData", JSONObject.toJSONString(context.getDataMap()));
	insertMap.put("TrsState", "3");
	//默认初始插入版本都是1
	insertMap.put("Version", 1);
	return insertMap;
}

mybatis的sql语句

insert into NoticeInfo
(
JnlNo,
BackstageTransCode,
RequestTime,
RequestData,
TrsState,
Version
)
values(
#_JnlNo#,
#BackstageTransCode#,
#RequestTime#,
#RequestData#,
#TrsState#,
#Version#
)

报错原因是BLOB字段需要转换成二进制存储,因此
1.将sql中的#RequestData#修改为to_blob(#RequestData#)
2.将程序中的insertMap.put(“RequestData”, JSONObject.toJSONString(context.getDataMap()));修改为insertMap.put(“RequestData”, JSONObject.toJSONString(context.getDataMap()).getBytes());

发布了2 篇原创文章 · 获赞 0 · 访问量 28

猜你喜欢

转载自blog.csdn.net/shlyxq/article/details/104774192