我的石英例程仅运行一次,关机后不再运行

时间:2019-07-16 20:11:15

标签: java javafx

我的石英例程仅运行一次,关机后不再运行 在我的主要班级:

   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();  
        try {
        Scheduler s = StdSchedulerFactory.getDefaultScheduler();
        s.start();
        try {
            s.scheduleJob(j,t);
        } catch (Exception e) {
             e.printStackTrace();
        }
        s.shutdown();
        } catch (SchedulerException se) {
        se.printStackTrace();
        }
        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();
                    }           
    }    
        });

        }

它调用了我的工作,同时关闭了

我已经在没有运行工具的情况下对其进行了测试,并且继续出现相同的错误 我也想把我的wii放到可运行的地方

0 个答案:

没有答案