jdeppuser Posted September 8, 2016 Share Posted September 8, 2016 I have still been unable to successfully create a connection to a datasource. The actual connection works but it cannot reference the existing tables within that database. I posted on this before but would like to take an alternative approach by creating the report from within java code. For example I will query the database and then try and commit the data to a specific report..Connection conn = DriverManager.getConnection(connectionUrl);stmt = conn.createStatement();rs = stmt.executeQuery( query );JRResultSetDataSource rsdt = new JRResultSetDataSource(rs);JasperPrint jp;JasperReport jrpt = null;jrpt = JasperCompileManager.compileReport("Flower_Landscape.jrxml");InputStream is = this.getClass().getResourceAsStream("Flower_Landscape.jrxml");jrpt = JasperCompileManager.compileReport(is);jp = JasperFillManager.fillReport("HelloJasper/Flower_Landscape.jrxml", new HashMap(), rsdt);JasperViewer jv = new JasperViewer(jp);jv.setVisible(true);con.close(); [/code]I am looking for a tutorial or assistance on how to get this done. I thought I could manipulate the fields from the xml but I have no idea on how to do this. Link to comment Share on other sites More sharing options...
Solution hozawa Posted September 9, 2016 Solution Share Posted September 9, 2016 You just have to populate Java beans and use that as a datasource. Refer to the following page for a sample using Java bean with JasperReports.http://jasperreports.sourceforge.net/sample.reference/datasource/ Link to comment Share on other sites More sharing options...
jdeppuser Posted September 15, 2016 Author Share Posted September 15, 2016 sorry your answer and accidently clicked accepted; as yet to try. 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