패키지: com.batch.scheduler
1 2 3 4 5 6 7 8 9 10 11 | public class JobTask { private TruncTableDao dao; public void setDao(TruncTableDao dao) { this.dao = dao; } public void truncateTableJob() throws DataAccessException, Exception { System.out.println("[ Job Task 실행 ] = " + new Date()); dao.truncateTable(); // TRUNCATE TABLE } } |
패키지: com.batch.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // QuartzJobBean 을 상속 받아야 한다. public class QuartzService extends QuartzJobBean { private JobTask jobTask; public void setJobTask(JobTask jobTask) { this.jobTask = jobTask; } @Override protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { try { jobTask.truncateTableJob(); // TRUNCATE TABLE } catch (DataAccessException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } |
이제 JOB을 등록하기만 하면 된다.
댓글 없음:
댓글 쓰기