小编aos*_*aos的帖子

Spring的存储过程 - 从过程返回的结果始终为空

我正在使用Spring的JdbcTemplate和StoredProcedure类.我无法让存储过程类为我工作.

我在oracle数据库上有一个存储过程.它的签名是

CREATE OR REPLACE PROCEDURE PRC_GET_USERS_BY_SECTION
(user_cursor OUT Pkg_Types.cursor_type
 , section_option_in IN Varchar2
 , section_in IN Varchar2) AS ....
Run Code Online (Sandbox Code Playgroud)

哪里

TYPE cursor_type IS REF CURSOR;
Run Code Online (Sandbox Code Playgroud)

我创建了以下存储过程类来从oracle过程中获取信息

    private class MyStoredProcedure extends StoredProcedure 
{
    public MyStoredProcedure(JdbcTemplate argJdbcTemplate) 
    {
        super(argJdbcTemplate, "PRC_GET_USERS_BY_SECTION");
        declareParameter(new SqlOutParameter("output", OracleTypes.CURSOR));
        declareParameter(new SqlParameter("input1", Types.VARCHAR));
        declareParameter(new SqlParameter("input2", Types.VARCHAR));
        compile();          
    }


    public Map<String, Object> execute() {

        Map<String, Object> inParams = new HashMap<String, Object>();
        inParams.put("input1", "BG");
        inParams.put("input2", "FE");
        Map output = execute(inParams);
        return output;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在我的一个DAO类中的方法中调用它

    public List<String> getUserListFromProcedure() throws BatchManagerException …
Run Code Online (Sandbox Code Playgroud)

java oracle stored-procedures jdbc spring-jdbc

15
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

jdbc ×1

oracle ×1

spring-jdbc ×1

stored-procedures ×1