即使关闭后实例仍保持打开状态

时间:2019-07-16 00:29:59

标签: java javafx quartz

我有一个用石英制作的例程,但是当我关闭我的应用程序时,它一直在运行,我想是因为有这个例程,因为以前不是这样 我有一个serverocket可以阻止多个实例

我的例行程序屏幕

@Override
public void start(Stage stage) throws Exception {

    JobDetail j = JobBuilder.newJob(ChecarJob.class).build();
    Trigger t = TriggerBuilder.newTrigger().withIdentity("CroneTrigger")
            .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(60).repeatForever()).build();  
    Scheduler s = StdSchedulerFactory.getDefaultScheduler();
    s.start();
    s.scheduleJob(j,t);

    Parent root = FXMLLoader.load(getClass().getResource("/Fxmls/Principal.fxml")); //carrega fxml
    Scene scene = new Scene(root); //coloca o fxml em uma cena
    stage.setScene(scene); // coloca a cena em uma janela
    stage.show(); //abre a janela
    setStage(stage);

}

我的工作:

   public void execute(JobExecutionContext context) throws JobExecutionException {       
    Platform.runLater(new Runnable() {  
    @Override
    public void run() {
        System.out.println("Executou!");
                try {
                    String verStatus = "SELECT COUNT(*) FROM equipamento_requisicao";
                    PreparedStatement stmt = con.prepareStatement(verStatus);
                        ResultSet rsStatus = stmt.executeQuery();
                        if(rsStatus.next()){
                        Alerts a = new Alerts();
                        int Resultado = rsStatus.getInt(1);
                        if(Resultado>Sessao.getInstancia().getQtdRegistroBD()){
                        Sessao.getInstancia().setQtdRegistroBD(Resultado);
                                                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("SUCESS");
                        alert.setHeaderText("SUCESS");
                        alert.setContentText("SUCESS");
                        alert.showAndWait();
                        }
                        else if(Resultado<Sessao.getInstancia().getQtdRegistroBD()){
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("FAIL");
                        alert.setHeaderText("FAIL");
                        alert.setContentText("FAIL");
                        alert.showAndWait();
                        Sessao.getInstancia().setQtdRegistroBD(Resultado);
                        } 
                        else{
                        //aq não irei fazer nada.
                        }
                        }
                    }catch (Exception e) {
            e.printStackTrace();
                    }           
    }    
        });

        }

0 个答案:

没有答案