没有params的JdbcTemplate和存储过程

时间:2018-04-25 14:36:35

标签: spring-boot jdbc oracle12c spring-jdbc jdbctemplate

我想使用JdbcTemplate在Spring Boot中调用存储过程。

在我的Oracle DB中:

CREATE OR REPLACE PACKAGE BODY P_MENU AS 
..
procedure menusVegans
  is
..
END;

来自我的Java应用程序。我试过了

jdbcTemplate.update("call P_MENU.menusVegans");

jdbcTemplate.execute("P_MENU.menusVegans");

jdbcTemplate.execute("call P_MENU.menusVegans");

jdbcTemplate.execute("execute call P_MENU.menusVegans");

SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate)

                .withProcedureName("P_MENU.menusVegans");
        simpleJdbcCall.execute(null);

所有错误。

1 个答案:

答案 0 :(得分:1)

而不是使用

call P_MENU.menusVegans

您应该使用匿名PL / SQL块:

BEGIN P_MENU.menusVegans; END