Error generating report with parameter id

0

I'm making a small system print a budget by passing the id. The following situation occurs; By netBeans I pass the id when prompted and the normal report appears.

ButwhenIdogeneratethereportthroughmyprogramitlookslikethis:

Mymethodthatgeneratesthereport:

publicvoidimprimeRelatorio(){ConexaoMySqlco=newConexaoMySql();co.setUrl("jdbc:mysql://localhost:3306/poc");
        co.setUsuario("root");
        co.setSenha("");
        String src = "C:\Users\Administrador\Documents\Eduardo\ControleOrcamento\src\vendas\orcamento.jasper";


        Map<String, Object> parametros = new HashMap<String, Object>();
        parametros.put("id",  (Integer.parseInt(inpId.getText())));



        JasperPrint jasperPrint = null;
        try {
            jasperPrint = JasperFillManager.fillReport(src, parametros, co.getConnection());
        } catch (JRException ex) {
            Logger.getLogger(TelaControle.class.getName()).log(Level.SEVERE, null, ex);
        }
        JasperViewer view = new JasperViewer(jasperPrint, false);
        view.setVisible(true);

    }
    
asked by anonymous 15.08.2017 / 02:57

1 answer

2

The problem was in the sql of jasperReport it was initially like this:

SELECT * FROM orcamento  WHERE id= $P{Id};

Then I changed to $P{id}; and solved the problem.

    
15.08.2017 / 05:23