Jasper Reports 6.7.0 生成报告很慢

Jasper Reports 6.7.0 generating report is slow

我正在使用 Jasper Reports 6.7.0 但报告生成速度很慢。

我只为数据库中的一条记录生成报告,但不知道为什么性能不佳。

I've referred some questions from stack overflow but isn't helpful
JasperReports fillReport too slow and resource consuming

我在单击按钮时使用以下代码在 JavaFX 应用程序中生成报告。

@FXML
private void viewReport(ActionEvent e) {
        Followup followup = followupTable.getSelectionModel().getSelectedItem();
        if (followup != null) {
            int fuRprtId = followup.getFuId();
            try {
                FileInputStream fis = new FileInputStream("src/com/homeo/reports/report1.jrxml");
                BufferedInputStream bis = new BufferedInputStream(fis);
                Map map = new HashMap();
                map.put("fuId", fuRprtId);
                Class.forName("com.mysql.jdbc.Driver");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/OPD", "root", "");

                JasperReport jasperReport = (JasperReport) JasperCompileManager.compileReport(bis);
                JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, con);

                JasperViewer.viewReport(jasperPrint, false);
            } catch (SQLException | ClassNotFoundException | FileNotFoundException | JRException ex) {
                Logger.getLogger(FollowUpController.class
                        .getName()).log(Level.SEVERE, null, ex);
            }
        }  

SQL 语法:

SELECT
     followup.`full name` AS followup_full_name,
     followup.`complaints` AS followup_complaints,
     followup.`remedy` AS followup_remedy,
     followup.`fu id` AS followup_fu_id,
     followup.`patientid` AS followup_patientid,
     followup.`date` AS followup_date,
     patient.`age` AS patient_age,
     patient.`address` AS patient_address,
     patient.`ref by` AS patient_ref_by,
     patient.`occupation` AS patient_occupation,
     patient.`diagnosis` AS patient_diagnosis,
     patient.`mother` AS patient_mother,
     patient.`matgrandmother` AS patient_matgrandmother,
     patient.`mat grandfather` AS patient_mat_grandfather,
     patient.`mat uncle` AS patient_mat_uncle,
     patient.`mat aunt` AS patient_mat_aunt,
     patient.`pat uncle` AS patient_pat_uncle,
     patient.`pat aunt` AS patient_pat_aunt,
     patient.`patgrand mother` AS patient_patgrand_mother,
     patient.`pat grandfather` AS patient_pat_grandfather,
     patient.`husband` AS patient_husband,
     patient.`wife` AS patient_wife,
     patient.`children` AS patient_children,
     patient.`brother` AS patient_brother,
     patient.`sister` AS patient_sister,
     patient.`phone` AS patient_phone,
     patient.`gender` AS patient_gender,
     patient.`dob` AS patient_dob,
     patient.`patnt id` AS patient_patnt_id,
     patient.`father` AS patient_father
FROM
     `patient` patient INNER JOIN `followup` followup ON patient.`patnt id` = followup.`patientid` where `fu id` = $P{fuId}  

It is taking approx 8 seconds to load

如何加速?

Also report don't load when I build an app

我很好奇为什么它变慢了。
它太慢了 approx 8 to 9 seconds

但我忽略了它并继续按原样构建,但现在无论如何报告都没有显示。

因为我已经选择了 slowness 的问题并且没有帮助。
我更改了我的代码,它解决了我对 jasper 报告的所有问题。

I don't recommend following code I guess it is old fashioned and not proper way to do

   FileInputStream fis = new FileInputStream("src/com/homeo/reports/report1.jrxml");
    BufferedInputStream bis = new BufferedInputStream(fis);
    Map map = new HashMap();
    map.put("fuId", fuRprtId);
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/OPD", "root", "");

    JasperReport jasperReport = (JasperReport) JasperCompileManager.compileReport(bis);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, con);

    JasperViewer.viewReport(jasperPrint, false);

I used following code which is too much faster than above code. Takes approx 2 seconds to load

try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/OPD", "root", "")) {
    InputStream inputStream = getClass().getResourceAsStream("/com/homeo/reports/report1.jasper");

    JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, map, con);
    JasperViewer.viewReport(jasperPrint, false);
    con.close();  
}
  } catch (SQLException | ClassNotFoundException | JRException ex) {
        Logger.getLogger(FollowUpController.class
                .getName()).log(Level.SEVERE, null, ex);
}  

To make above code work properly

你必须使用已编译的
report.jsper 而不是 report.jrfxml
并使用
"/com/reports/report.jsper" 而不是 "/src/com/reports/report.jsper"