0

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!

1 Answers1

0

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")
yvoytovych
  • 871
  • 4
  • 12
  • Thanks for the reply. I tried it but it ran into the below error. `org.springframework.dao.InvalidDataAccessApiUsageException: Unable to determine the correct call signature - no procedure/function/signature for 'RUN_JOB' ` I tried to create an SP that would run the job, but that doesn't seem to work either. The SP doesn't compile. – shazwashere Feb 22 '18 at 14:24
  • try using `.withSchemaName` instead of `. withCatalogName ` – yvoytovych Feb 22 '18 at 15:04
  • Tried that, fails with the same error. It appears that the oracle package dbms_scheduler is not accessible this way. Is there a way to access this package, its only then we'll have access to the run_job SP inside. – shazwashere Feb 24 '18 at 05:31