Jump to content
We've recently updated our Privacy Statement, available here ×

Add data to existing report template using java


jdeppuser
Go to solution Solved by hozawa,

Recommended Posts

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

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...