简体   繁体   中英

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:

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.

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 = 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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