I am trying to create JR report which is taking start_date and end_date as parameters.
The query:
SELECT * FROM emp WHERE joining_date BETWEEN $P{frm_date} AND $P{to_date}
The code:
Date from_date = dt_from_date.getDate();
Date to_date = dt_to_date.getDate();
java.sql.Date frm_dte = new java.sql.Date(from_date.getTime());
java.sql.Date to_dte = new java.sql.Date(to_date.getTime());
try {
HashMap map = new HashMap();
map.put("$P{frm_date}", frm_dte);
map.put("$P{to_date}", to_dte);
JasperPrint jp = JasperFillManager.fillReport(is, map, con);
JRViewer jv = new JRViewer(jp);
JFrame jf = new JFrame();
jf.getContentPane().add(jv);
jf.validate();
jf.setVisible(true);
jf.setSize(new Dimension(800, 600));
jf.setLocation(300, 100);
jf.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
} catch (JRException ex) {
ex.printStackTrace();
}
Can we pass Two Parameters to same Column in the table? Eg:
map.put("joining_date", frm_dte);
map.put("joining_date", to_dte);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…