Java: Generating Report in iReport Between Two Dates Timestamp

0

I am finalizing a small system made in Java and MySQL and with reports being generated by iReport and need to generate a report displaying values between two dates.

  • In MySQL the query is working perfectly:

  • DirectoniReportisalsoworkingperfectly:

  • TheproblemsarewhenItrytopasstheseparametersthroughJava:

    try{//UsandoaclasseHashMapparacriarumfiltroHashMapfiltroInicio=newHashMap();HashMapfiltroFinal=newHashMap();filtroInicio.put("inicial", Timestamp.valueOf("2018-04-20 00:00:00"));
                filtroFinal.put("final", Timestamp.valueOf("2018-04-21 23:59:59"));
                //Usando a classe JasperPrint para preparar a impressão do relatório
                JasperPrint print = JasperFillManager.fillReport("C:/Users/Master/Documents/InfoX/reports/caixa2.jasper", filtroInicio, conexao);
    
                //Exibindo o relatório através da classe JasperViewer
                JasperViewer.viewReport(print, false);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
    

    First problem: With the above code, at the time of generating the report through the system, it informs that the document does not contain pages , as if the parameters were null .

    Second problem: If you notice this code snippet: JasperPrint print = JasperFillManager.fillReport("C:/Users/Master/Documents/InfoX/reports/caixa2.jasper", filtroInicio, conexao); Summer I can only pass a parameter, which is the initial one, how would I go about passing the two parameters through Java? / p>

    Third problem: In the future I will still need to replace the date values entered within the parentheses by values obtained through a JTextField.

    I need help urgently, thank you in advance! If the doubt was not very clear, I will try to clarify it to the maximum.

        
    asked by anonymous 04.05.2018 / 20:46

    0 answers