执行此代码需要近 30 秒才能显示。
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance();
JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory",
"net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String driverName = "com.mysql.jdbc.Driver";
String connection_string = "jdbc:mysql://localhost:3306/nursery";
String username = "root";
String password = "";
Connection connection;
File file = new File("D:/reports/sowing.jrxml");
try {
JasperDesign jasperDesign = JRXmlLoader.load(file);
Map<String, Object> params = new HashMap<String, Object>();
params.put("reportTitle", "Hello Report World");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
System.out.println("IN the window");
Class.forName(driverName);
connection = DriverManager.getConnection(connection_string, username, password);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, connection);
JasperViewer.viewReport(jasperPrint);
} catch (Exception e) {
}
}
});
有什么解决方案可以尽可能快地执行吗?