dbsynctimer.java
来自「数据库远程同步软件NetBeans项目源文件 项目采用Jdesktop集成组件」· Java 代码 · 共 105 行
JAVA
105 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package databasesyncdesktopapplication.PlanTaskPool.examples;import com.qixuan.jdbc.common.SourceDataBaseBean;import com.qixuan.jdbc.common.TargetDataBaseBean;import databasesyncdesktopapplication.PlanTaskPool.DbSyncTask;import databasesyncdesktopapplication.PlanTaskPool.Scheduler;import databasesyncdesktopapplication.PlanTaskPool.iterators.DailyIterator;import java.text.SimpleDateFormat;import java.util.Date;/** * * @author mjw917 */public class DbSyncTimer { private SourceDataBaseBean sourceBean; private TargetDataBaseBean targetBean; private DbSyncTask dbtask; private final int model; private boolean cannel=true; private final Scheduler scheduler = new Scheduler(); private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss.SSS"); private final int hourOfDay, minute, second; public boolean isCannel() { return !cannel; } public DbSyncTimer(SourceDataBaseBean sourceBean,TargetDataBaseBean targetBean, int hourOfDay, int minute, int second, int model) { this.sourceBean=sourceBean; this.targetBean = targetBean; this.hourOfDay = hourOfDay; this.minute = minute; this.second = second; this.model = model; dbtask = new DbSyncTask(sourceBean, targetBean); } public DbSyncTimer(SourceDataBaseBean sourceBean,TargetDataBaseBean targetBean, Date date, int model) { this.sourceBean=sourceBean; this.targetBean = targetBean; hourOfDay = Integer.valueOf(new SimpleDateFormat("HH").format(date)); minute = Integer.valueOf(new SimpleDateFormat("mm").format(date)); second = Integer.valueOf(new SimpleDateFormat("SS").format(date)); this.model = model; dbtask = new DbSyncTask(sourceBean, targetBean); } public DbSyncTask getDbtask() { return dbtask; } public void setDbtask(DbSyncTask dbtask) { this.dbtask = dbtask; } public SourceDataBaseBean getSourceBean() { return sourceBean; } public TargetDataBaseBean getTargetBean() { return targetBean; } public void setTargetBean(TargetDataBaseBean targetBean) { this.targetBean = targetBean; } public DbSyncTimer(int hourOfDay, int minute, int second, int model) { this.hourOfDay = hourOfDay; this.minute = minute; this.second = second; this.model = model; dbtask = new DbSyncTask(sourceBean, targetBean); } public void start() { scheduler.schedule(dbtask, new DailyIterator(hourOfDay, minute, second)); System.out.println(hourOfDay + "," + minute + "," + second); System.out.println("Wake up! " + "It's " + dateFormat.format(new Date())); dbtask.run(); if (model == 0) { dbtask.cancel(); }cannel=false; } public boolean Iscancel() { return cannel; } public static void main(String[] args) { DbSyncTimer dst = new DbSyncTimer(0, 40, 20, 0); dst.start(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?