我在用springs运行一个存储过程 SimpleJdbcCall
这样地:
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("example_proc");
jdbcCall.execute();
// do other stuff on other subsystems
// the sysout below is just an example - the real scenario was somewhat different
System.out.println("Supposedly after the end of the stored procedure call");
存储过程运行了很长一段时间,并且与之后应该发生的事情重叠。
存储过程是用microsoft的sql server方言编写的,如下所示:
CREATE PROCEDURE example_proc
AS
BEGIN
INSERT INTO example_table_1 SELECT * FROM example_table_2
UPDATE example_table_1 SET col1 = 'a' WHERE ...
END
问题是:如何确保 SimpleJdbcCall
等待存储过程完成?
1条答案
按热度按时间c7rzv4ha1#
有一种方法可以解决这个问题:让存储过程返回一些东西,然后在jdbc调用中检索它。
存储过程是:
现在它返回了一些东西,jdbc调用可以等待: