使用ibatis进行批量更新出错,各位大牛帮忙看看这是哪儿的问题

曈霸天下 曈霸天下 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
使用的firebird数据库,运行一段时间就会报以下错误。但是感觉代码没有问题啊,不知道问题出在哪里了。。。

INFO | jvm 1 | 2014/07/12 22:32:42 | com.ibatis.common.jdbc.exception.NestedSQLException:
INFO | jvm 1 | 2014/07/12 22:32:42 | --- The error occurred in com/emerson/upscoutersrvr/sql/firebird/System.xml.
INFO | jvm 1 | 2014/07/12 22:32:42 | --- The error occurred while executing mapped statement.
INFO | jvm 1 | 2014/07/12 22:32:42 | --- Check the System.updateRealData.
INFO | jvm 1 | 2014/07/12 22:32:42 | --- Check the statement or the result map.
INFO | jvm 1 | 2014/07/12 22:32:42 | --- Cause: java.lang.reflect.UndeclaredThrowableException
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:67)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.emerson.upscoutersrvr.util.CommonDAO.executeUpdate(CommonDAO.java:202)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.emerson.upscoutersrvr.device.NetAccessDevice.processRealData(NetAccessDevice.java:959)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.emerson.upscoutersrvr.device.NetAccessDevice.process(NetAccessDevice.java:607)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.emerson.upscoutersrvr.device.UpsDevice.run(UpsDevice.java:716)
INFO | jvm 1 | 2014/07/12 22:32:42 | at java.lang.Thread.run(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | Caused by: java.lang.reflect.UndeclaredThrowableException
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:101)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:869)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:824)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:817)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:293)
INFO | jvm 1 | 2014/07/12 22:32:42 | at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at java.lang.reflect.Method.invoke(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.common.jdbc.SimpleDataSource$SimplePooledConnection.invoke(SimpleDataSource.java:958)
INFO | jvm 1 | 2014/07/12 22:32:42 | at $Proxy0.prepareStatement(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:494)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.execution.SqlExecutor.access$000(SqlExecutor.java:39)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.execution.SqlExecutor$Batch.addBatch(SqlExecutor.java:583)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.execution.SqlExecutor.addBatch(SqlExecutor.java:104)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:197)
INFO | jvm 1 | 2014/07/12 22:32:42 | at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
INFO | jvm 1 | 2014/07/12 22:32:42 | ... 8 more
INFO | jvm 1 | 2014/07/12 22:32:42 | Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.parseSqlInfo(AbstractJavaGDSImpl.java:2349)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlDescribeBind(AbstractJavaGDSImpl.java:1118)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.gds.impl.GDSHelper.prepareStatement(GDSHelper.java:196)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractStatement.prepareFixedStatement(AbstractStatement.java:1119)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractPreparedStatement.prepareFixedStatement(AbstractPreparedStatement.java:1176)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:124)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:41)
INFO | jvm 1 | 2014/07/12 22:32:42 | at sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at java.lang.reflect.Constructor.newInstance(Unknown Source)
INFO | jvm 1 | 2014/07/12 22:32:42 | at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:90)
INFO | jvm 1 | 2014/07/12 22:32:42 | ... 23 more

执行语句如下:
<update id="updateRealData" parameterClass="java.util.Map">
UPDATE
SIGNAL
SET
REAL_VALUE_NR = #realValve#
<isNotEmpty prepend="," property="alarmSign">
ALARM_SIGN_TX = #alarmSign#
</isNotEmpty>
WHERE
EQUIP_ID = #deviceId#
AND SIGNAL_NR = #channel#
</update>

源码简化如下:

Map param = new WeakHashMap();
param.put("deviceId", getDeviceId());
startTransaction();
this.startBatch();
for (int i = 0; i < realDataSize; i++)
{
String status = "0";
try {
float fRealValue = 0;

if(isUpdateSignalData() ||
!(upsRealDataStatus.get(i).equals(oldStatus.get(i))))
{
param.put("alarmSign", status);
param.put("channel", new Short((short)(i + 1))); //信号ID+1
param.put("realValve", new Float(fRealValue));
executeUpdate("System.updateRealData", param);
}
}

this.executeBatch();
commitTransaction();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
endTransaction();
}
...全文
评论 3
收藏 已收藏
分享
返回顶部
曈霸天下
Web 开发 81,107 成员 341,720 内容