spring - 异常参数索引超出范围:Java 中使用 Spring Batch ItemReader 时为 0
问题描述
我正在创建一个 Spring Batch Job,其 Item Reader 的定义如下:
StoredProcedureItemReader<GenData> spir = new StoredProcedureItemReader<GenData>();
//Sybase data source specified
spir.setDataSource(ds1);
//Sybase stored proc : exec procedure_name
spir.setProcedureName(proc1);
spir.setRowMapper(objectRowMapper());
其中 objectRowMapper 是:
private RowMapper<GenData> objectRowMapper() {
return new RowMapper<GenData>() {
@Override
public GenData mapRow(ResultSet rs, int rowNum) throws SQLException {
GenData gdo = new GenData();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
ArrayList<String> colNames = new ArrayList<String>();
for(int i = 1; i <= columnCount; i++) {
String name = rsmd.getColumnName(i);
colNames.add(name);
//object has a map where we put the <columnName, columnValue>
//these are supposed to be dynamic in the code hence made like this
gdo.objectData.put(name, rs.getString(name));
}
return gdp;
}
}
上面的代码抛出错误: 执行存储过程;JZ0SB:参数索引超出范围:0;嵌套异常是 java.sql.SQLException:JZ0SB:Paramater index out of range: 0
有人可以告诉这是什么意思。尤其是最后的数字 0,因为它似乎是这里最大的线索。
谢谢!!
解决方案
推荐阅读
- html - HTML 表格宽度按比例设置
- html - 从 Django 应用程序将 QuickChart.io 图像嵌入 HTML
- reactjs - 在功能组件中使用道具
- bash - Shell 脚本,带有变量的 curl 作为 url 的一部分
- vb.net - 组合框在 VB.net 中以 winform 显示两次
- sql - Postgresql 使用 CASE 根据其他数据的存在返回不同的数据
- php - OAUTH:Facebook API 因重定向 URL 参数错误而引发错误
- javascript - 如何编写一个Javascript函数来按顺序从字符串中获取所有回文子序列?
- node.js - AgoraIO Web + Heroku
- matlab - 从符号微分的结果创建函数句柄的问题