我的代码未引发任何异常,并且报告也未生成,代码中是否存在任何问题
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自动注册驱动程序,通常不需要手动加载驱动程序类。
完成打印
答案 0 :(得分:0)
将数据库连接的jdbc驱动程序类名称从com.mysql.jdbc.Driver
更改为com.mysql.cj.jdbc.Driver