Error generating report with parameter id

Asked

Viewed 220 times

0

I am making a small system to print a budget by passing the id as parameter. The following situation occurs; By netbeans step id when prompted and normal report appears.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

But when I do generate the report by my program it brings so:

inserir a descrição da imagem aqui

My method that generates the report:

 public void imprimeRelatorio() {

        ConexaoMySql co = new ConexaoMySql();
        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);

    }

1 answer

2


The problem was in the sql of jasperReport was initially so:

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

so I switched to $P{id}; and solved the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.