I am trying to create a batch class to insert a custom object. The following is the code,

global class EmployeeBatchCreate implements Database.batchable <Integer> { 

    global Iterable<integer> start(Database.BatchableContext bc) {
      return new  IntegerIterator(1000); 

   global void execute(Database.batchableContext info, List<Integer> scope){ 
       String randStr = '';
       final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
        for(integer j=0;j<10;j++){
         while (randStr.length() < 6) {
            Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length());
            randStr += chars.substring(idx, idx+1);
        system.debug(randStr) ;
             System.debug('in execute' );
                String firstName = 'First'+ randStr;
                String lastName = 'Last' + randStr ;
                List<employee__c> employeeList = new List<employee__c>();
                employee__c emp;
                Integer employeeLoopSize = 100;
            for (Integer i = 0; i < employeeLoopSize; i++){
                Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 1825);
                Date dd = date.newInstance(1995, 01, 01);
                emp = new employee__c(first_Name__c = firstName + i , last_name__c = lastName + i ,birth_date__c = dd);
        insert employeeList;
      // return 'finish';

   global void finish(Database.batchableContext info){     


I called the execute method like this:

Database.executeBatch(new EmployeeBatchCreate(), 100);

Error showed --

Line: 1, Column: 10

Method does not exist or incorrect signature: void executeBatch(employeeBatchCreate, Integer) from the type Database

Any help will be really appreciated.

  • 1
    Were you able to save EmployeeBatchCreate class in the first place? – Pranay Jaiswal Sep 18 '18 at 13:34
  • @PranayJaiswal the error would be invalid type if he was unable to save it to begin with. – Ronnie Sep 19 '18 at 1:36

There is a custom Database class or interface defined in your code base. This is conflicting with the system library called Database. You'll want to rename this class eventually, but for now, you should be able to do the following:

System.Database.executeBatch(new EmployeeBatchCreate(), 100);

By using System, you're explicitly asking for the built-in library function instead of the custom class. It is strongly recommended that you do not name classes, variables, etc after any standard library method, because it can have undesired effects in the rest of your code. Names like Test, Database, Account, and so on should be avoided, because they can potentially cause compilation errors in large areas of your code at once.

  • i tried System.Database.executeBatch(new EmployeeBatchCreate(), 100); still I face error Line: 1, Column: 17 Method does not exist or incorrect signature: void executeBatch(employeeBatchCreate, Integer) from the type Database. :) – Midhun K Raj Sep 18 '18 at 13:46
  • @MidhunKRaj Are you doing this in Winter 19 or Summer 18 release? I wonder if something is broken, then, because it should still work as far as I can tell. – sfdcfox Sep 18 '18 at 13:56
  • @MidhunKRaj Well, then, the code you've put in your question doesn't match what is in your code base. Or you have a bug somewhere in the system. There's absolutely nothing wrong with the code as written in the post; I actually copy-pasted it to my org, took out the irrelevant parts in the middle, and it ran as expected. – sfdcfox Sep 18 '18 at 14:06
  • I am working on free developer instance of Salesforce. And the code that I showed here is exactly the same that i am using. But, I am facing issue. – Midhun K Raj Sep 18 '18 at 14:35
  • @MidhunKRaj Aside from the fact that you will run out of space before you create 100k records, the code should otherwise work. I'm not sure what else to tell you. There's something wrong with your code that isn't outlined here. I don't know what it is, but you'll need to find it. – sfdcfox Sep 19 '18 at 2:06

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.