解决oracle in 超过1000 报错问题

 @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException
    {
        try
        {
            log.debug("Start ShelfTimeTask ...");
            List<TimingTask> tasks = taskService.findAllShelfTimingTask();
            if(tasks.size()<1000)
            {
               
                if (tasks != null && tasks.size() != 0)
                {
                    taskService.batchOnDownTask(tasks);
                }
            }
            else
            {   
                List<TimingTask> task = new ArrayList<TimingTask>(0);
                int len = tasks.size();
                for(int i=0;i< len; i++)
                {
                    if((i % 1000) == 0 && i>0)
                    {
                        
                        task = new ArrayList<TimingTask>(0);
                        task.add(tasks.get(i));
                    }
                    else
                    {
                        task.add(tasks.get(i));
                    }
                    if((i+1)%1000 == 0)
                    {
                        taskService.batchOnDownTask(task);   
                    }
                }
                
            }
            log.debug("ShelfTimeTask complete...");
        }
        catch (Exception e)
        {
            addLog(e);
        }
    }

你可能感兴趣的:(解决oracle in 超过1000 报错问题)