0

I have Created a batch scheduler which need to run for Every 5 min. but i am getting this error. can any one please help me out.

Error: Compile Error: Method does not exist or incorrect signature: void schedule(String, String, Batchclassname) from the type System at line 6 column 16

My Code:

global class Batchclassname_Schedule implements Schedulable{
    global static void execute(SchedulableContext SC) 
    {
        String sch = '0 5 * * * ?';
        System.schedule('Schedule Job Name 1',sch,New Batchclassname());

    }
}
  • Does BatchClassName implements Database.Batchable? – CommonCoreTawan Nov 21 '18 at 12:09
  • 3
    You need to use Database.executeBatch(new Batchclassname() ); – Pranay Jaiswal Nov 21 '18 at 12:42
  • Try to look on this thread. here I hope it helps. – Leorah Sumarong Feb 7 at 15:25
2

The Schedulable interface method signature is (String, String, Schedulable). Inferring from your class names, you use a Database.Batchable<SObject> instance as your third argument. As mentioned in the comments already, you should execute your batch from within this method instead of scheduling the job again.

Also note it is more efficient to implement both interfaces on the same class since the scheduling adds very few LOC and your batch logic should usually be in a service anyway.

public with sharing class MyScheduledBatch implements Schedulable, Database.Batchable<SObject>
{
    public void execute(SchedulableContext context) { Database.executeBatch(this); }
    public Database.QueryLocator start(Database.BatchableContext context)
    {
        // implementation
    }
    public void execute(Database.BatchableContext context, List<SObject)
    {
        // implementation
    }
    public void finish(Database.BatchableContext context)
    {
        // implementation
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.