java – Quartz Scheduler不使用JDBCStore在DB中插入记录
发布时间:2020-12-15 02:18:03 所属栏目:Java 来源:网络整理
导读:配置Quartz作业, public static void schedule(IEntity entity,Date startdate) { try { JobDetail job = JobBuilder.newJob(StatingUpdateJob.class) .withIdentity("UpdateStagingRecords" + entity.getId(),"StgToProduction").build(); JobDataMap data
配置Quartz作业,
public static void schedule(IEntity entity,Date startdate) { try { JobDetail job = JobBuilder.newJob(StatingUpdateJob.class) .withIdentity("UpdateStagingRecords" + entity.getId(),"StgToProduction").build(); JobDataMap data = new JobDataMap(new HashMap<>()); data.put("Entity",entity); job.getJobBuilder().setJobData(data); Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); Date enddate = new Date(); enddate.setTime(startdate.getTime() + 6000000); CronTrigger cronTrigger = TriggerBuilder.newTrigger() .withIdentity("UpdateStagingRecords" + entity.getId(),"StgToProduction").startAt(startdate) .withSchedule(CronScheduleBuilder.cronSchedule("0 0/5 * 1/1 * ? *") .withMisfireHandlingInstructionDoNothing()) .endAt(enddate).build(); Connection connection = DBConnectionManager.getInstance().getConnection("myDS"); System.out.println(connection); scheduler.scheduleJob(job,cronTrigger); scheduler.start(); } catch (Exception e) { System.out.println("Something went wrong"); e.printStackTrace(); } } 然后将quartz.properties放在我的类路径中 org.quartz.scheduler.instanceName=JavacodeGeeksScheduler org.quartz.scheduler.instanceId=99199 org.quartz.scheduler.rmi.export=false org.quartz.scheduler.rmi.proxy=false org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount=3 org.quartz.context.key.QuartzTopic=QuartzPorperties org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.tablePrefix=QRTZ_ org.quartz.jobStore.dataSource=myDS org.quartz.jobListener.NAME.class=com.javacodegeeks.quartz.MyJobListener org.quartz.dataSource.myDS.driver=com.mysql.jdbc.Driver org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost/test org.quartz.dataSource.myDS.user=admin org.quartz.dataSource.myDS.password=admin org.quartz.dataSource.myDS.maxConnections=30 我的工作成功创建并正确触发.但是,工作细节并没有放在数据库中.这是我的桌子 不确定我还需要配置什么. 解决方法
奇怪的是,石英数据源URL不接受与本机jdbc url相同的内容.
当我将jdbc:mysql:// localhost / test更改为 jdbc:mysql://localhost:3306/test 它工作了(感谢@pringi和@Bilbo Baggins). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Java包不存在
- java – BigDecimal数字的格式
- Android 发送广播简易工具类
- 使用java同步不同服务器中的两个表的有效方法
- Java Collections类:sort()升序排序、reverse()降序排序、
- java 基础知识之网络通信(TCP通信、UDP通信、多播以及NIO)
- java编译器的目标版本“jsr14”与JDK7 / 8
- 使用OpenSAML在Java中使用SAML 2.0解密加密断言
- java – 将新行放入mysql表时要向Response.created添加什么
- selenium – junit.framework.AssertionFailedError:在寄存