2015-09-28 59 views
0

JRBeanCollectionDataSource在碧玉如何使用

try { 
    //Connecting to the MySQL database 

    Class.forName("com.mysql.jdbc.Driver"); 
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital", "root" ,"root"); 

    String report="C:\\Users\\DELL\\report10.jrxml"; 

    JasperReport jasperreport=JasperCompileManager.compileReport(report); 
    patientDB DataBeanList = new patientDB(); 

    ArrayList<patientBean> dataList = DataBeanList.getDataBeanList(); 

    JRBeanCollectionDataSource beanColDataSource = 
    new JRBeanCollectionDataSource(dataList); 
    Map<String,Object> parameters = new HashMap<String,Object>(); 

    JasperPrint jp=JasperFillManager.fillReport(jasperreport, parameters,beanColDataSource); 
    JasperViewer.viewReport(jp); 

} 
catch(Exception e) 
{ 
    out.println(e); 
} 

我在碧玉报告新试图从bean类,但没有价值发生,我花我的最后7天为这个

回答

0

请澄清,

你得到的错误是什么?

DataBeanList.getDataBeanList()是否返回带有值的对象?

Db连接配置是否正确?

jrxml的路径是否正确?(我认为你不需要路径中的双斜杠)