当前位置: 首页 > 知识库问答 >
问题:

spring“游标已关闭”异常与SimpleJDBCall

沃侯林
2023-03-14

存储过程工作正常。我已经在SQL导航器中测试过了,每次运行都很好。

这是我得到的异常堆栈:

组织。springframework。jdbc。UncategorizedSQLException:CallableStatementCallback;SQL的未分类SQLException[{call PKG_RPT_STE_DATA.GETCOREREPORTEXTRAS(?,,,,,,,,,,,?)}];SQL状态[null];错误代码[0];光标已关闭。;嵌套的例外是java。sql。SQLException:游标已关闭。组织。springframework。jdbc。支持AbstractFallbackSQLExceptionTranslator。翻译(AbstractFallbackSQLExceptionTranslator.java:83)组织。springframework。jdbc。支持AbstractFallbackSQLExceptionTranslator。翻译(AbstractFallbackSQLExceptionTranslator.java:80)组织。springframework。jdbc。果心jdbc模板。执行(JdbcTemplate.java:969)org。springframework。jdbc。果心jdbc模板。调用(JdbcTemplate.java:1003)org。springframework。jdbc。果心易于理解的打电话。ExecuteCallineral(AbstractJdbcCall.java:391)org。springframework。jdbc。果心易于理解的打电话。doExecute(AbstractJdbcCall.java:354)org。springframework。jdbc。果心易于理解的SimpleJDBCall。执行(SimpleJdbcCall.java:181)

这是我的Java代码(使用Spring 3.0.5)

private class GetStandardReportExtrasSPV2{
    int nAreaLevel;
    int nAssignment;
    int nUserRole;
    int nAcisNum = 0;
    String strAreaMenu;     
    String strLDO = null;

    private SimpleJdbcCall procGetReportExtras;

    public GetStandardReportExtrasSPV2(DataSource ds, int nUserRole, String strAreaMenu,
            int nAssignment, int nAreaLevel, String strLDO, int nAcisNum) {

        JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
        jdbcTemplate.setResultsMapCaseInsensitive(true);

        this.procGetReportExtras =
                new SimpleJdbcCall(jdbcTemplate)
                    .withCatalogName("PKG_RPT_STE_DATA")
                    .withProcedureName("GetCoreReportExtras")
                     .returningResultSet("CURREPORTLIST",
                                ParameterizedBeanPropertyRowMapper.newInstance(Report.class));
    }

    public List<Report> getReportsList() {

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put("PNASSIGNMENT", new Integer(nAssignment));
        params.put("PNUSERROLE", new Integer(nUserRole));
        params.put("PSAREAMENU", strAreaMenu);
        params.put("PNAREALEVEL", new Integer(nAreaLevel));
        params.put("PSLDO", strLDO);
        params.put("PNACISNUMBER", new Integer(nAcisNum));

        if (nAcisNum > 0)
            params.put(ACIS_NUMBER, nAcisNum);

        SqlParameterSource in = new MapSqlParameterSource().addValues(params);

        Map m = procGetReportExtras.execute(in);
        return (List) m.get("CURREPORTLIST");
    }

}

这是Oracle存储过程:

   PROCEDURE GetCoreReportExtras
    ( pnAssignment IN NUMBER,
      pnUserRole in NUMBER,
      psAreaMenu in VARCHAR2,
      pnAreaLevel in NUMBER,
      curReportList OUT outcur,
      psLDO in VARCHAR2 default 'none',
      pnAcisNumber in NUMBER default 0) IS

   BEGIN
        --start working through roles...
        IF substr(psAreaMenu,1,1) <> '7' and pnAssignment > 74999 --CAM Area of some sort
        THEN
            -- these users never get an HBDC or QBR...
           --NOTHING WILL BE RETURNED
           open curReportList for
                    SELECT FILE_NAME, NULL AS DISPLAY_TEXT

                    FROM CORE_REPORT_NAME
                    WHERE STATIC_REPORT_TYPE = 'XXXXXXXX';
        ELSE -- Non-CAM, Non-GPO...Check traditional Sales first...
            IF substr(psAreaMenu,1,1) = '7' THEN --Sales Assignment of some sort
                -- retrieve the HBDC File Name for these sales users...
                open curReportList for
                    SELECT FILE_NAME, 'Anemia Worksheet Link' AS DISPLAY_TEXT
                    FROM CORE_REPORT_NAME
                    WHERE STATIC_REPORT_TYPE = 'HBDCANEMIA'
                    UNION
                    SELECT FILE_NAME, 'HBDC Bone Metabolism Worksheet Link' AS DISPLAY_TEXT
                    FROM CORE_REPORT_NAME
                    WHERE STATIC_REPORT_TYPE = 'HBDC_BONE';
                -- sales-perspective users don't see a QBR...
                --NOTHING IS RETURNED FOR QBR
            ELSE -- Callpoint or Top-SDO Assignment
                IF pnUserRole = 11 THEN --TOP SDO
                    --  These users don't see HBDC...
                    --NOTHING IS RETURNED FOR HBDC
                    -- but they do get the QBR...
                    open curReportList for
                        SELECT FILE_NAME, 'CIDO Report Selection' AS DISPLAY_TEXT
                        FROM CORE_REPORT_NAME
                        WHERE STATIC_REPORT_TYPE = 'QBR'
                        and SHORT_NAME = psAreaMenu;
                --ELSE -- Some form of Callpoint
                    -- these perspectives don't get QBR or HBDC
                    --NOTHING WILL BE RETURNED
                END IF;
            END IF;
        END IF;
   END GetCoreReportExtras;

有什么线索能告诉我为什么会有例外吗?

共有1个答案

怀齐智
2023-03-14

我把我的代码从它所在的包含类中取出,它运行得很好。

 类似资料: