Error preparing statement in Jasper

Posted by Augusto on Stack Overflow See other posts from Stack Overflow or by Augusto
Published on 2010-06-13T19:28:20Z Indexed on 2010/06/13 19:32 UTC
Read the original article Hit count: 323

Filed under:
|
|

Hi,

I'm trying to create a report with Jasper, but I keep getting this exception when running from my app (runs ok from IReport):

net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query 

Here's the query I'm using:

SELECT
     produtos.`Descricao` AS produtos_Descricao,
     saidas.`Quantidade` AS saidas_Quantidade,
     saidas.`Data` AS saidas_Data,
     motivossaidas.`Motivo` AS motivossaidas_Motivo
FROM
     `produtos` produtos INNER JOIN `saidas` saidas ON produtos.`Id` = saidas.`Id_Produto`
     INNER JOIN `motivossaidas` motivossaidas ON saidas.`Id_MotivoSaida` = motivossaidas.`id` WHERE
     motivossaidas.`motivo` = $P{MOTIVO}

and the parameter definition:

<parameter name="MOTIVO" class="java.lang.String"/>

The exception occurs when I do

JasperPrint jasperPrint = JasperFillManager.fillReport(relatorio, parametros);

where relatorio is a JasperReport object loaded with JRLoader.loadObject(URL) and parametros is a HashMap with the following key/values:

REPORT_CONNECTION => MySQL JDBC connection,

MOTIVO => "Venda"

I really don't know what to do here. I keep getting the exception event if I use a query without any parameters.

Why do I get this exception? What should I do here?

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about jdbc