Java – quartz scheduler does not use JDBC store to insert records in dB

Configure quartz jobs,

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();
    }

}

Then put quartz Properties in my classpath

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

My work was successfully created and triggered correctly However, the details of the work are not placed in the database This is my desk

I'm not sure what else I need to configure

Solution

Strangely, the quartz data source URL does not accept the same content as the native JDBC URL

When I change JDBC: MySQL: / / localhost / test to

jdbc:MysqL://localhost:3306/test

It works (thanks @ pringi and @ Bilbo Baggins)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>