makking jar文件后,jasper报告无效

时间:2013-06-25 09:01:54

标签: java netbeans-6.9

我已经完成了我的java项目,并使用ireport来显示报告 它工作得很好,但是当我制作我的jar文件并运行项目时它无法正常工作。

注意:我的报告保存到报告包中,它属于netbeans的src文件夹。

我的生成报告代码

try
    {
        java.sql.Connection icon=DB_Connect.getConnection();
        //String report="C:\\Users\\kinng\\Documents\\NetBeansProjects\\air_kingdom\\reports\\com_report.jrxml";
        JasperDesign jd = JRXmlLoader.load("C:\\Users\\kinng\\Documents\\NetBeansProjects\\air_kingdom\\reports\\com_report.jrxml");
        String sql = "select b.*,a.*,c.* from (select Booking_id, group_concat(routing) as routing,group_concat(ticket_no) as ticket_no,group_concat(carrier) as carrier,group_concat(travel_date) as travel_date from tckt_reservation.trcb group by Booking_id) as b join tckt_reservation.booking as a on a.Booking_id=b.Booking_id join tckt_reservation.company as c on a.company=c.cName where a.company='"+cname+"'";
        JRDesignQuery newquary= new JRDesignQuery();
        newquary.setText(sql);
        jd.setQuery(newquary);
        JasperReport jr= JasperCompileManager.compileReport(jd);
        JasperPrint jp = JasperFillManager.fillReport(jr, null,icon);
        JasperViewer.viewReport(jp);
        setVisible(true);
    }catch(Exception e)
    {
        JOptionPane.showMessageDialog(null, e);
    }

0 个答案:

没有答案