我知道这很容易使用JdbcTemplate
调用存储过程,但是这里的情况有所不同。我想调用一个不返回任何东西的存储过程函数。我尝试了以下代码,但工作正常,但我们无论如何都没有使用RowCountCallbackHandler
,这很浪费
jdbcTemplate.query("select * from status_update(?) ",
new Object[]{statusId},
new int[]{Types.INTEGER}, new RowCountCallbackHandler());
我正在寻找的是类似下面的内容,显然不可用
jdbcTemplate.query("select * from status_update(?) ",
new Object[]{statusId},
new int[]{Types.INTEGER});
我想知道是否缺少使用JdbcTemplate执行无效存储过程的任何其他方法
您可以使用SimpleJdbcCall
类。这使execute()
方法过载,其中一种方法可以满足您的需要。
SimpleJdbcCall spCall = new SimpleJdbcCall(yourJdbcTemplate);
spCall.withProcedureName(SP_NAME);
spcall.execute(inParamsAsMap);
这将执行执行。如果您的SP具有输出参数,则可以执行以下操作。
Map<String, Object> output = spcall.execute(inParamsAsMap);