这是我在编译jrxml文件时遇到的错误:
Compiling to file... /home/moshe/NetBeansProjects/Billing/src/billing/report2.jasper
Compilation running time: 299!
Filling report...
Locale: English (India)
Time zone: Default
Error filling print... Error executing SQL statement for : report2
net.sf.jasperreports.engine.JRException: Error executing SQL statement for : report2
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:143)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:686)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:606)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1277)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:897)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:877)
at org.openide.util.RequestProcessor$Task.run(Unknown Source)
at org.openide.util.RequestProcessor$Processor.run(Unknown Source)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to usenear '"temp_bill" temp_bill, "customer_details" customer_details WHERE temp_' at line 38
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
... 11 more
Print not filled. Try to use an EmptyDataSource...
根据错误消息,我检查了xml文件中的第38行,它是:
<![CDATA[SELECT
temp_bill.`bill_number`AS temp_bill_bill_number,
temp_bill.`sl_no`AS temp_bill_sl_no,
temp_bill.`cust_id`AS temp_bill_cust_id,
temp_bill.`cust_name`AS temp_bill_cust_name,
temp_bill.`date`AS temp_bill_date,
temp_bill.`item_code`AS temp_bill_item_code,
temp_bill.`item_name`AS temp_bill_item_name,
temp_bill.`tax`AS temp_bill_tax,
temp_bill.`unit_price`AS temp_bill_unit_price,
temp_bill.`quantity`AS temp_bill_quantity,
temp_bill.`gross_value`AS temp_bill_gross_value,
temp_bill.`cash_discount`AS temp_bill_cash_discount,
temp_bill.`net_value`AS temp_bill_net_value,
temp_bill.`qty_discount`AS temp_bill_qty_discount,
temp_bill.`net_total`AS temp_bill_net_total,
temp_bill.`cess`AS temp_bill_cess,
temp_bill.`tot_tax`AS temp_bill_tot_tax,
temp_bill.`grand_total`AS temp_bill_grand_total,
temp_bill.`remarks`AS temp_bill_remarks,
temp_bill.`billingAddress`AS temp_bill_billingAddress,
temp_bill.`tot_in_words`AS temp_bill_tot_in_words,
temp_bill.`deliv_note_no`AS temp_bill_deliv_note_no,
//line 38 is the next line*************************
temp_bill.`deliv_note_date`AS temp_bill_deliv_note_date,
temp_bill.`purchase_order_no`AS temp_bill_purchase_order_no,
temp_bill.`purchase_order_date`AS temp_bill_purchase_order_date,
temp_bill.`despatch_document_no`AS temp_bill_despatch_document_no,
temp_bill.`despatch_document_date`AS temp_bill_despatch_document_date,
temp_bill.`terms_of_delivery`AS temp_bill_terms_of_delivery,
customer_details.`TIN`AS customer_details_TIN,
customer_details.`cstRegNo`AS customer_details_cstRegNo,
customer_details.`phone_land`AS customer_details_phone_land,
customer_details.`phone_mob`AS customer_details_phone_mob,
customer_details.`fax`AS customer_details_fax,
customer_details.`email`AS customer_details_email,
customer_details.`cust_id`AS customer_details_cust_id FROM
"temp_bill" temp_bill,
"customer_details" customer_details WHERE
temp_bill.`cust_id` = customer_details.`cust_id`]]>
根据错误消息,我检查了xml文件中的第38行,我发现查询没有任何问题,我使用 NetBeans 插件生成报告。将customer_details.TIN的类型从 bigint 更改为 varchar 后,此问题就开始了。我检查了xml文件并确保TIN的类型为 varchar
<textField>
<reportElement x="27" y="77" width="241" height="11"/>
<textElement textAlignment="Center" markup="none">
<font size="8"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{customer_details_TIN}]]></textFieldExpression>
</textField>
答案 0 :(得分:1)
检查对应的手册 您的MySQL服务器版本 在'“temp_bill”附近使用正确的语法 temp_bill,“customer_details” customer_details WHERE temp_'at 第38行
当MySql告诉你在第38行看到它时,它意味着从第一行开始的第38行
我认为你应该回顾一下:
FROM“temp_bill”temp_bill, “customer_details”
是否需要这些引号?试着删除它们:)