开发者社区> 问答> 正文

Jfinal Batch批量保存问题:报错

@JFinal 你好,想跟你请教个问题:

我用的是1.8版本 ,  今有一需求做一个批量保存功能,运行报错,怎么会提示索引超出范围?

详情,如下:

Sql: 
com.jfinal.plugin.activerecord.ActiveRecordException: com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围。
    at com.jfinal.plugin.activerecord.DbPro.batch(DbPro.java:860)
    at com.jfinal.plugin.activerecord.Db.batch(Db.java:488)
    at com.demo.qa.Qa_Controll.saveBatch(Qa_Controll.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
    at com.jfinal.plugin.activerecord.tx.Tx.intercept(Tx.java:76)
    at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
    at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
    at com.demo.common.MyContextPathHandler.handle(MyContextPathHandler.java:31)
    at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围。
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:667)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObjectNoType(SQLServerPreparedStatement.java:852)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:875)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setObject(NewProxyPreparedStatement.java:365)
    at com.jfinal.plugin.activerecord.DbPro.batch(DbPro.java:818)
    at com.jfinal.plugin.activerecord.DbPro.batch(DbPro.java:858)
    ... 24 more

 

代码如下:  

	String sql ="";
		QA_det3  dt1=new QA_det3();		
		dt1.set("dh", "test-001001");
		dt1.set("iFPS_id", 1);
		dt1.remove("id");
		
		QA_det3 dt2=new QA_det3();		
		dt2.set("dh", "test-001001");
		dt2.set("iFPS_id", 2);
		dt2.remove("id");
		
		List<QA_det3>  modelOrRecordList=new ArrayList<QA_det3>();
		
		modelOrRecordList.add(dt1);
		modelOrRecordList.add(dt2);
		
		try {
			int[] result = Db.batch(sql, "dh,iFPS_id,nD1,nD2", modelOrRecordList, 1);
		
			setAttr("flag", 1);
			setAttr("msgText", "保存成功,请核对!");
			renderJson();
			
		} catch (Exception e) {
			e.printStackTrace();
			setAttr("flag", 0);
			setAttr("msgText", "保存失败,请核对!");
			renderJson();
		}
	    

展开
收起
kun坤 2020-06-14 13:59:33 748 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
《Apache Flink-重新定义计算》PDF下载 立即下载
大批量处理excel文件到ODPS中方案 立即下载
低代码开发师(初级)实战教程 立即下载

相关实验场景

更多