gpt4 book ai didi

Java Spring JDBC Oracle 存储过程返回 null

转载 作者:行者123 更新时间:2023-12-04 06:34:54 28 4
gpt4 key购买 nike

这个问题在这里已经有了答案:




10年前关闭。




Possible Duplicate:
Spring's Stored Procedure - results coming back from procedure always empty.



我有以下代码,虽然我知道调用应该导致内容,但我总是得到一个空的结果集,有人可以建议为什么吗?
ParameterizedRowMapper<ExamPaper> mapper = new ParameterizedRowMapper<ExamPaper>() {

public ExamPaper mapRow(ResultSet rs, int rowNum) throws SQLException {


logger.info("in the row mapper with"+rs.toString());
logger.info("in the row mapper with x no of rows " +rowNum);

ExamPaper examPaper = new ExamPaper();
examPaper.setCampus(rs.getString("campus"));
examPaper.setTitle(rs.getString("title"));
examPaper.setPaper(rs.getString("paper"));
examPaper.setCode(rs.getString("code"));
examPaper.year.add(rs.getString("year"));
examPaper.semester.add(rs.getString("semester"));
return examPaper;
}
};

Map params = new HashMap();
params.put("ic_search_string","fluid");
params.put("ic_location_flag", "unmc");
logger.info("calling stored procedure");
OracleStoredProcedure storedProcedure = new OracleStoredProcedure(getDataSource(),"pkg_exam_papers.p_get_exam_papers",logger, mapper);

Map results = storedProcedure.execute(params);
logger.info(results.size());
public class OracleStoredProcedure extends StoredProcedure 
{
private Log logger;
public OracleStoredProcedure(DataSource dataSource,String storedProcedureName, Log logger,ParameterizedRowMapper mapper)
{
super();
this.logger = logger;

setDataSource(dataSource);
setFunction(false);
setSql(storedProcedureName)

declareParameter(new SqlParameter("ic_search_string", OracleTypes.VARCHAR));
declareParameter(new SqlParameter("ic_location_flag", OracleTypes.VARCHAR));
declareParameter(new SqlOutParameter("orc_results", OracleTypes.CURSOR, mapper));
declareParameter(new SqlOutParameter("on_errcode", OracleTypes.INTEGER));
declareParameter(new SqlOutParameter("oc_errmess", OracleTypes.CHAR));

compile();

}

public Map execute(Map parameters)
{
Map out = new HashMap();

try
{
out = super.execute(parameters);
}
catch (NullPointerException nullPointerException)
{
logger.error("Exception when executing stored procedure: " + nullPointerException.getMessage());
}
catch(Exception exception)
{
logger.error("Exception when executing stored procedure: " + exception.getMessage());
}

return out;
}
}

最佳答案

我认为一年前的另一个类似问题回答了您的问题:Spring's Stored Procedure - results coming back from procedure always empty

关于Java Spring JDBC Oracle 存储过程返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4995799/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com