We haven't gone too far to complete a job class because it's closely related to your actual application, but in your job process
What happens if an exception is made? Sir you look down ... .....
------------------------------------I'm a split line------------------------------------------------
If Sir looked at the previous few rotten dregs of the article, will know that the following will first paste code, a job class, a scheduling class.
But this time a little different is not rotten slag, but rotten more slag,-.-
Two job classes: Badjob1.java and Badjob2.java
A scheduling class: Jobexceptionexample.java
Badjob1.java[Java] View plain copy import java.text.simpledateformat; import java.util.date; import org.quartz.disallowconcurrentexecution; import org.quartz.job; import org.quartz.jobexecutioncontext; import org.quartz.jobexecutionexception; import org.quartz.persistjobdataafterexecution; @ persistjobdataafterexecution @DisallowConcurrentExecution Public class badjob2 implements Job { @Override public void execute (jobexecutioncontext context) throws JobExecutionException { // Task Execution Time simpledateFormat dateformat = new simpledateformat ("Yyyy-mm-dd hh:mm:ss"); string jobname = context.getjobdetail (). GetKey (). GetName (); system.out.println ("---" + jobname + " in [ " + dateformat.format (New date ()) + " ] Execute!! ") ; system.err.println ("--- error occurred in BadJob 2 , will stop running!! "); jobexecutionexception e2 = new jobexecutionexception (New exception ()); // settings will automatically remove This task trigger, so this task will no longer execute the //e2.setunschedulealltriggers (True); // Throw exception throw e2; } }
Badjob2.java [Java] View plain copy import java.text.simpledateformat; import java.util.date; import org.quartz.disallowconcurrentexecution; import org.quartz.job; import org.quartz.jobexecutioncontext; import org.quartz.jobexecutionexception; import org.quartz.persistjobdataafterexecution; @PersistJobDataAfterExecution @DisallowConcurrentExecution public class badjob2 implements job { @Override public void execute (jobexecutioncontext context)