简体   繁体   English

碧玉中的JRBeanCollectionDataSource如何使用

[英]JRBeanCollectionDataSource in jasper how to use

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);
}

i am new in jasper report trying to get value from bean class but nothing happen i spend my last 7 days for this 我是刚在碧玉报告中尝试从bean类中获取价值的新手,但是什么也没有发生,我为此花了最后7天的时间

Please clarify, 请澄清,

What is the error you are getting? 您遇到什么错误?

does the DataBeanList.getDataBeanList() return objects with values? DataBeanList.getDataBeanList()返回带有值的对象吗?

Is Db connection configuration is correct? Db连接配置是否正确?

the path to jrxml is correct?(I think you don't need double slash in path) jrxml的路径正确吗?(我认为您不需要在路径中使用双斜杠)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM