-1

我想在我的项目中添加一个石英作业调度程序,但是当我运行项目时出现这样的错误,我如何让石英作业调度程序读取我的 database.properties?

非常感谢您的回答,Igor 先生,我的问题是我已经有一个 database.properties 但是当我运行我的项目时,石英作业调度程序运行,并且控制器作业将连接到数据库,甚至出现这样的错误虽然我也打开了连接

这是我的 database.properties :

development.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
development.username=xxxx
development.password=xxxx
development.url=jdbc:sqlserver://10.10.5.45;databaseName=xxxxxxxxxxxxx;

这是我的石英工作班:

package app.controllers.api.prosesgaji;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.javalite.activejdbc.Base;
import org.javalite.common.Convert;
import org.javalite.http.Http;
import org.javalite.http.Post;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import app.controllers.api.pemeliharaandata.KomponenGajiPegawaiHitungGajiController;
import app.models.Mstpegawai;
import core.io.enums.HttpResponses;

public class QuartzJobProsesGaji implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        // TODO Auto-generated method stub
        LocalDate localDate = LocalDate.now();
        int bulan = localDate.getMonthValue();
        int tgl = localDate.getDayOfMonth();

        try {
            String tglGaji = Convert.toString(localDate);

            String nip = "";

            String kddati1 = "";
            String kddati2 = "";
            int kdStapeg = 0;
            String tmtStop = "";
            int no = 1;

            System.out.println("\nStart Create Gaji");

            Base.open();
            Base.openTransaction();

            List<Map> dataPegawai = new ArrayList<>();
            dataPegawai = Mstpegawai.getPegawaiQuartzTestBeberapaPegawai(tglGaji);

            Mstpegawai mstPegawai = new Mstpegawai();

            for (Map map : dataPegawai) {
                System.out.println("\nPegawai ke = "+no);

                nip = Convert.toString(map.get("nip"));
                System.out.println(" - nip = "+nip);

                kddati1 = Convert.toString(map.get("kddati1"));
                System.out.println(" - kddati1 = "+kddati1);

                kddati2 = Convert.toString(map.get("kddati2"));
                System.out.println(" - kddati2 = "+kddati2);

                kdStapeg = Convert.toInteger(map.get("kdstapeg"));
                System.out.println(" - kdStapeg = "+kdStapeg);

                tmtStop = Convert.toString(map.get("tmtstop"));
                System.out.println(" - tmtStop = "+tmtStop);

                KomponenGajiPegawaiHitungGajiController hitungGaji = new KomponenGajiPegawaiHitungGajiController();
                hitungGaji.prosesGajiInduk(mstPegawai.fromMap(map), tglGaji);

                no++;
            }

            Base.close();

            System.out.println("\nDone Create Gaji\n");

        } catch (Exception e) {
            e.printStackTrace();

        }

    }

}

那么,为什么 Base.open() 不起作用?

4

1 回答 1

0

您需要熟悉文档:http: //javalite.io/database_configuration。您可能没有提供配置文件http://javalite.io/database_configuration#property-file-configuration但正在使用DBConnectionFilter,它不知道在哪里连接。

于 2018-10-02T18:47:27.857 回答