Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code you need in order to get two values from two combo-boxes, add them to a HashMap and pass the map to iReport. These paramaters, for this example "<strong>storeName</strong>" and "<strong>actionCode</strong>", are used to specify values for the query which is stored inside the iReport. The report jasper file is "<strong>../ireps/AccessCounter.jrxml</strong>". The viewer is a JDialog. If you have no parameters to pass to your report just skip the map.put. con is the connection to the database.</p> <p>Make sure that you include the necessary jar file to your path.</p> <pre><code>try { String shopName = jComboBox1.getSelectedItem().toString(); String actionCode = jComboBox2.getSelectedItem().toString(); HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;(); map.put("storeName", shopName); map.put("actionCode", actionCode); URL reportFileURL = getClass().getResource("../ireps/AccessCounter.jrxml"); File reportFile = new File(reportFileURL.toURI()); JasperDesign jasperDesign = JRXmlLoader.load(reportFile); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, con); JasperViewer jv = new JasperViewer(jasperPrint); JDialog viewer = new JDialog(this, "Batch Report", true); viewer.setBounds(jv.getBounds()); viewer.getContentPane().add(jv.getContentPane()); viewer.setResizable(true); viewer.setIconImage(jv.getIconImage()); viewer.setVisible(true); } catch (JRException exc) { System.out.println(exc.getMessage()); } catch (URISyntaxException exs) { System.out.println(exs.getMessage()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload