Gostaria de sabe, como posso fazer um relatório inserindo Data Inicial e Data Final, estou usando o Ireport, sei que tenho que ter dois parâmetros, só que não consigo fazer no java. Segue a script do bando e o metodo.
SELECT
tbacampar.`OrA` AS tbacampar_OrA,
tbacampar.`DataAcamp` AS tbacampar_DataAcamp,
tbacampar.`Situacao` AS tbacampar_Situacao,
tbacampar.`AreaAcamp` AS tbacampar_AreaAcamp,
tbacampar.`Atendente` AS tbacampar_Atendente,
tbacampar.`valor` AS tbacampar_valor,
tbacampar.`DiasAcamp` AS tbacampar_DiasAcamp,
tbacampar.`ObsAcamp` AS tbacampar_ObsAcamp,
tbacampar.`IdCamp` AS tbacampar_IdCamp
FROM tbacampar
where DataAcamp > $P{DataInicio} and $P{DataFim};
public void imprimirPorData() {
String src = "src\\Relatorios\\Relatorio-Por-Data.jasper";
JasperPrint jasperPrint = null;
int confirma = JOptionPane.showConfirmDialog(null, "Relatório Por Data?", "Atenção", JOptionPane.YES_NO_OPTION);
if (confirma == JOptionPane.YES_OPTION) {
HashMap filtro = new HashMap();
txtDataInicio = new JDateChooser("dd/MM/yyyy", "##/##/#####", '-');
txtDataFim = new JDateChooser("dd/MM/yyyy", "##/##/#####", '-');
try {
filtro.put("DataInicio", new java.util.Date());
filtro.put("DataFim", new java.util.Date());
jasperPrint = JasperFillManager.fillReport(src, filtro, conexao);
// linha exibe relatorio
JasperViewer jasp = new JasperViewer(jasperPrint, false);
jasp.setVisible(true);
} catch (JRException ex) {
Logger.getLogger(OpcaoRelatorios.class.getName()).log(Level.SEVERE, null, ex);
}
}
}