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 个解决方案
#1
反射的时候字段对不上。
parameterClass为什么不用javabean?
parameterClass为什么不用javabean?
#2
感觉使用map也能实现,而且我的字段名和sql中的都是一样的啊
#3
不是光字段名一样就能映射上,你看看ibatis的用map的文档。
#1
反射的时候字段对不上。
parameterClass为什么不用javabean?
parameterClass为什么不用javabean?
#2
感觉使用map也能实现,而且我的字段名和sql中的都是一样的啊
#3
不是光字段名一样就能映射上,你看看ibatis的用map的文档。