najib.mozahem Posted April 5, 2014 Share Posted April 5, 2014 I am using JasperReports to create reports in Java. I use the following code to try to generate the report:connect.query = "SELECT employee_id, employee_first_name, employee_last_name, salary, date_of_enrollment FROM employees";try { connect.prstmt = connect.con.prepareStatement(connect.query); connect.rs = connect.prstmt.executeQuery(); JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(connect.rs); try { InputStream input = new FileInputStream(new File("jrxml/employees2.jrxml")); JasperDesign jasperDesign = JRXmlLoader.load(input); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,new JREmptyDataSource()); OutputStream output = new FileOutputStream(new File("reports/employees.pdf")); JasperExportManager.exportReportToPdfStream(jasperPrint, output); } catch (JRException e) { e.printStackTrace(); } catch (FileNotFoundException y) { y.printStackTrace(); } } catch (SQLException e) { e.printStackTrace(); } the problem is that the fields appear empty in the jasper report even though the query does return values. I populated a table with the same query and it worked fine. I should also note that if I create the report by embedding the query into the jrxml file then everything works fine, but it is important that I not do that because the parameters of the query aill change from time to time. Can anyone help me with this? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now