java NetBeans, чтобы показать ireport документ с параметрами, но получить ошибку, чтобы выбрать дату, он сказал, что нет документа в отчете - PullRequest
0 голосов
/ 24 апреля 2020
private void tprint1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
      JasperReport jasRep;
    JasperPrint jasPri;
    JasperDesign jasDes;

    try {


         String newDate = "";
   String date = JOptionPane.showInputDialog(null, "Enter the date: ","Date Converter", JOptionPane.PLAIN_MESSAGE); 
   newDate = date.replace('-', '/');
   JOptionPane.showMessageDialog(null, "Here is the new formatted date: "+newDate);


        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost/bengkel","root","");
        HashMap params = new HashMap ();
        params.put("dt1",date);
        File report = new File ("src/bengkel/pertanggal.jrxml");
        jasDes = JRXmlLoader.load(report);
        jasRep = JasperCompileManager.compileReport(jasDes);
        jasPri = JasperFillManager.fillReport (jasRep,params,con);
        JasperViewer.viewReport(jasPri,false);

    } catch (ClassNotFoundException e) {
    JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (JRException e) {
        JOptionPane.showMessageDialog(null, e.getMessage());
    }
} 

enter image description here

...