我正在尝试使用Java swing jdk 1.4开发一个调度程序。我用过石英1.5.2。 jar用于安排。但我面临的问题是,每当我关闭框架时,调度程序也会自动断开连接。请建议。请在下面找到我的调度程序方法。
public void Scheduler() throws ParseException, IOException{
JobDetail job = new JobDetail();
job.setName(textField_2.getText());
job.setJobClass(HelloJob.class);
SimpleTrigger trigger=new SimpleTrigger();
trigger.setName(textField_2_trigg.getText());
trigger.setStartTime(new Date(System.currentTimeMillis() + 1000));
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
trigger.setRepeatInterval(30000);
FileOutputStream fout = new FileOutputStream(textField_path.getText()+"\\aaa.ser");
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(job);
oos.writeObject(trigger);
try{
FileInputStream fin = new FileInputStream(textField_path.getText()+"\\aaa.ser");
ObjectInputStream ois = new ObjectInputStream(fin);
// job = (JobDetail) ois.readObject();
// ois.close();
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
//JobDetail job=(JobDetail) oos.
/*HSSFCell cellA1 = titleRow.getCell((short) 0);
String a1Val = cellA1.getStringCellValue();
HSSFCell cellA2 = titleRow.getCell((short) 1);
String a2Val = cellA2.getStringCellValue();*/
scheduler.scheduleJob(job = (JobDetail) ois.readObject(), trigger=(SimpleTrigger) ois.readObject());
}catch(Exception ex){
ex.getMessage();
}
JOptionPane.showMessageDialog(null, "Scheduled");
//fileOut1.close();
}