Hello,
I am developing one small application. And want to implement in quartz job scheduler. I have implemented it. But now I am getting confused how to integrate it with mysql 5.0 database due to Job store. I want to JDBCJobstore. I have searched on www. But not found the option that how to integrate it with mysql. And how to use quartz.properties for this. I have downloaded 1.6.5 quartz. And Please tell if any one know which files are required to connect with MYSQL database only mysql database. I have created all quartz related table. and also added these properties as follows:
org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
# Using RAMJobStore
## if using RAMJobStore, please be sure that you comment out
## org.quartz.jobStore.tablePrefix, org.quartz.jobStore.driverDelegateClass, org.quartz.jobStore.dataSource
#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
# Using JobStoreTX
## Be sure to run the appropriate script(under docs/dbTables) first to create database/tables
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
# Configuring JDBCJobStore with the Table Prefix
org.quartz.jobStore.tablePrefix = QRTZ_
# Using DriverDelegate
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# Using datasource
org.quartz.jobStore.dataSource = qzDS
# Define the datasource to use
org.quartz.dataSource.qzDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.qzDS.URL = jdbc:mysql://localhost:3306/student_management
org.quartz.dataSource.qzDS.user = sms_user
org.quartz.dataSource.qzDS.password = password.1
org.quartz.dataSource.qzDS.maxConnections = 30
After that I have created one java class that execute cron job as :
public class JDBCJobStoreRunner {
public void task() throws SchedulerException {
// Initiate a Schedule Factory
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
// Retrieve a scheduler from schedule factory
Scheduler scheduler = schedulerFactory.getScheduler();
String[] triggerGroups;
String[] triggers;
triggerGroups = scheduler.getTriggerGroupNames();
System.out.println("helloooo---->" + triggerGroups.toString());
for (int i = 0; i < triggerGroups.length; i++) {
System.out.println("hello within i--->" + i);
triggers = scheduler.getTriggerNames(triggerGroups);
for (int j = 0; j < triggers.length; j++) {
System.out.println("hello within jjjjjjjjjj--->" + j);
Trigger tg = scheduler.getTrigger(triggers[j], triggerGroups[i]);
if (tg instanceof SimpleTrigger && tg.getName().equals("simpleTrigger")) {
((SimpleTrigger) tg).setRepeatCount(100);
// reschdule the job
scheduler.rescheduleJob(triggers[j], triggerGroups[i], tg);
// unschedule the job
//scheduler.unscheduleJob(triggersInGroup[j], triggerGroups[i]);
}
}
}
// start the scheduler
scheduler.start();
}
public static void main(String args[]) {
try {
JDBCJobStoreRunner qRunner = new JDBCJobStoreRunner();
qRunner.task();
} catch (Exception e) {
e.printStackTrace();
}
}
}
It is not showing any output. Please help. I really needed.
Thanks in advance.
Manveer