PROCEDURE 的参数数量不正确;预期为 1,得到 0。无法从代码中确定错误
Posted
技术标签:
【中文标题】PROCEDURE 的参数数量不正确;预期为 1,得到 0。无法从代码中确定错误【英文标题】:Incorrect number of arguments for PROCEDURE; expected 1, got 0. Cant determine the error from code 【发布时间】:2012-04-22 19:16:50 【问题描述】://设置输入参数
Map<String,Object> inParams = new HashMap<String,Object>();
inParams.put("Sig",resourceHistoryBean.getId());
List<ResourceHistoryBean> resourceHistoryList= new ArrayList<ResourceHistoryBean>();
//定义存储过程
try
SimpleJdbcCall readResult = new SimpleJdbcCall(getDataSource())
.useInParameterNames("Sig")
.declareParameters(new SqlParameter("Sig", Types.VARCHAR))
.withProcedureName("SP_ResourceAllocationDtls")
.withSchemaName("hrms")
.returningResultSet("ResourceHistory", new ParameterizedRowMapper<ResourceHistoryBean>()
public ResourceHistoryBean mapRow(ResultSet rs, int rowNum)
throws SQLException
ResourceHistoryBean bean = new ResourceHistoryBean();
resourceHistoryBean.setProjectName(rs.getString(RH_PROJECT_NAME));
return bean;
);
readResult.compile();
// 执行存储过程
Map<String, Object> out = readResult.execute(inParams);
resourceHistoryList = (List<ResourceHistoryBean>) out.get("ResourceHistory");
【问题讨论】:
【参考方案1】:看起来我能够找到上述问题的替代解决方案(参数传递到存储过程并使用映射类):
public List<ResourceHistoryBean> getResourceHistory(final ResourceHistoryBean resourceHistoryBean)throws Exception
try
// call stored procedure and pass parameter to it
List resourceHistoryList = getJdbcTemplate().query(
"call hrms.SP_ResourceAllocationDtls(?)",
new Object[] resourceHistoryBean.getId(), new HistoryMapper());
return resourceHistoryList;
catch (Exception e)
throw e;
finally
closeTemplate();
// 映射器类
class HistoryMapper implements RowMapper, IDatabaseConstants
public Object mapRow(ResultSet rs, int rowNum) throws SQLException
ResourceHistoryBean resourceHistoryBean = new ResourceHistoryBean();
resourceHistoryBean.setProjectName(rs.getString(RH_PROJECT_NAME));
return resourceHistoryBean;
【讨论】:
以上是关于PROCEDURE 的参数数量不正确;预期为 1,得到 0。无法从代码中确定错误的主要内容,如果未能解决你的问题,请参考以下文章
TypeError:参数“x”的类型不正确(预期为cupy.core.core.ndarray,得到了numpy.ndarray)