Jasper报告未导出报告

问题描述 投票:-1回答:1

我的代码未引发任何异常,并且报告也未生成,代码中是否存在任何问题

Connection con = getConnection();
        HashMap<String,Object> param = new HashMap<String,Object>();
        try {
        param.put("order_id", 202);
        InputStream employeeReportStream = getClass().getResourceAsStream("/Invoice.jrxml");

        JasperReport jasperReport = JasperCompileManager.compileReport(employeeReportStream);

        JasperPrint jasperPrint=JasperFillManager.fillReport(jasperReport , param,con);


        JRExporter exporter = new JRPdfExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, new FileOutputStream("report.pdf")); 

        exporter.exportReport();

        System.out.println("done printing");

    }catch(Exception e) {
            e.printStackTrace();
        }finally {
            if (con != null) {
                try { con.close(); } catch (Exception e) {}
            }
        }

这是我的输出

正在加载类com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'。通过SPI自动注册驱动程序,通常不需要手动加载驱动程序类。完成打印

jasper-reports
1个回答
0
投票

将数据集的JDBC驱动程序类名称从com.mysql.jdbc.Driver更改为com.mysql.cj.jdbc.Driver

© www.soinside.com 2019 - 2024. All rights reserved.