简体   繁体   English

如何在春季从Java存储库中触发dbms_scheduler作业?

[英]How to trigger a dbms_scheduler job from Java repo in Spring?

I have an Oracle DB Scheduler job that I'm able to run directly using command: 我有一个Oracle DB Scheduler作业,可以使用以下命令直接运行:

EXEC dbms_scheduler.run_job('MY_SCHEDULER_JOB');

Now I'm trying to invoke the same job from my Java SpringBoot service where I'm using JDBCTemplate in Repo to run Select and Update queries on the DB. 现在,我试图从Java SpringBoot服务中调用同一作业,在该服务中,我在Repo中使用JDBCTemplate在数据库上运行Select和Update查询。

I've looked and not found any help on how I can do this. 我已经看过,但没有找到有关如何执行此操作的帮助。 Would appreciate any help. 将不胜感激。

Thanks! 谢谢!

I would use SimpleJdbcCall for this purpose 我将为此目的使用SimpleJdbcCall

SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(getJdbcTemplate());
simpleJdbcCall
      .withCatalogName("dbms_scheduler")
      .withProcedureName("run_job")
      .execute(new MapSqlParameterSource("JOB_NAME", "MY_SCHEDULER_JOB"));

Btw, you can pass here 顺便说一句,你可以通过这里

A job name or a comma-separate list of entries, where each is the name of an existing job 作业名称或用逗号分隔的条目列表,其中每个条目都是现有作业的名称

so this is also valid case : 所以这也是有效的情况:

new MapSqlParameterSource("JOB_NAME", "JOB1, JOB2, JOB3")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM