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);
}
我是jasper报告中的新手,试图从豆类中获取价值,但没有任何事情我花了我最近7天的时间
答案 0 :(得分:0)
请澄清,
你得到的错误是什么?
DataBeanList.getDataBeanList()是否返回值为?
的对象Db连接配置是否正确?
jrxml的路径是否正确?(我认为你不需要在路径中使用双斜杠)