在netbeans中生成空白碧玉报告

时间:2015-08-08 05:17:22

标签: java netbeans

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
        con = DbConnection.getConnection();
        JasperDesign jasperDesign = JRXmlLoader.load("outstanding.jrxml");

        String sql = "Select id, cust_name, day, location, total, advance, outstanding from atharwa.project where id='" + txtcheck.getText() + "' ";
        JRDesignQuery newQuery = new JRDesignQuery();
        newQuery.setText(sql);
        jasperDesign.setQuery(newQuery);
        JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, con);
        JasperViewer.viewReport(jasperPrint);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

0 个答案:

没有答案