当我尝试预览报告时,请返回此错误
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query :
SELECT `accounts`.`name` AS `accounts_name` FROM `accounts` WHERE `accounts`.`id` NOT IN (SELECT `tasks`.`parent_id` FROM `tasks` WHERE `tasks`.`date_modified` > DATE_SUB(now(), INTERVAL 3 OR 6 MONTH))
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:467)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:442)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:334)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query :
SELECT `accounts`.`name` AS `accounts_name` FROM `accounts` WHERE `accounts`.`id` NOT IN (SELECT `tasks`.`parent_id` FROM `tasks` WHERE `tasks`.`date_modified` > DATE_SUB(now(), INTERVAL 3 OR 6 MONTH))
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:377)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:196)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1119)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:691)
at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:434)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:508)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:120)
at java.lang.Thread.run(Thread.java:695)
Caused by: java.sql.SQLSyntaxErrorException: palabra desconocida:
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:267)
... 7 more
Caused by: org.hsqldb.HsqlException: palabra desconocida:
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserBase.read(Unknown Source)
at org.hsqldb.ParserBase.readThis(Unknown Source)
at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 10 more
发生了什么?
测试数据库连接没关系(我使用的是org.hsqldb.jdbcDriver),数据库是在Mysql中(如果我试试Mysql驱动程序,错误通信失败),那么Jasper的版本是6.0.0
代码是
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0 -->
<!-- 2015-10-27T13:56:22 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="CompanyReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a5bf3d64-d6b6-48c5-9c1e-412341420f11">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="84"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Canal4"/>
<queryString language="SQL">
<![CDATA[SELECT `accounts`.`name` AS `accounts_name` FROM `accounts` WHERE `accounts`.`id` NOT IN (SELECT `tasks`.`parent_id` FROM `tasks` WHERE `tasks`.`date_modified` > DATE_SUB(now(), INTERVAL 3 OR 6 MONTH))]]>
</queryString>
<field name="accounts_name" class="java.lang.String"/>
<background>
<band/>
</background>
<title>
<band/>
</title>
<pageHeader>
<band height="79">
<staticText>
<reportElement mode="Opaque" x="0" y="1" width="441" height="75" forecolor="#FFFFFF" backcolor="#000099" uuid="26217d12-c674-43a7-bc1a-bf78deeaec88"/>
<textElement verticalAlignment="Middle">
<font size="24"/>
</textElement>
<text><![CDATA[Informe detallado de empresa]]></text>
</staticText>
<line>
<reportElement x="0" y="76" width="555" height="1" forecolor="#666666" uuid="fdffb19d-6028-475b-950b-e79e2b1f99c8"/>
</line>
</band>
</pageHeader>
<columnHeader>
<band/>
</columnHeader>
<detail>
<band height="381">
<rectangle>
<reportElement x="1" y="4" width="554" height="24" forecolor="#CCFFFF" backcolor="#CCFFFF" uuid="0f212168-15c3-4f56-986f-459e65788377"/>
</rectangle>
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="258" width="555" height="1" uuid="7ad8233c-4bbe-4ccf-b271-4346d742f303"/>
</line>
<textField isStretchWithOverflow="true">
<reportElement x="80" y="7" width="284" height="20" uuid="1e5b0494-848f-48c2-8e3f-71859e5d6049"/>
<textElement>
<font size="11"/>
</textElement>
<textFieldExpression><![CDATA[$F{accounts_name}]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Opaque" x="0" y="6" width="70" height="21" forecolor="#006699" backcolor="#E6E6E6" uuid="95550a5a-8e1c-403d-8be1-cec0f685ec04"/>
<textElement textAlignment="Right">
<font size="11" isBold="true"/>
</textElement>
<text><![CDATA[Empresa :]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="23">
<textField>
<reportElement mode="Opaque" x="0" y="8" width="515" height="13" backcolor="#E6E6E6" uuid="6b37b78b-a8fe-497c-8266-7029bfa327e6"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement mode="Opaque" x="515" y="8" width="40" height="13" backcolor="#E6E6E6" uuid="95b2ed71-fa56-43af-bc36-44f93a377437"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="0" y="4" width="100" height="13" uuid="19ca911f-a36f-4549-b58f-866a11508e95"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="2" width="556" height="1" uuid="626fba8b-3b52-4e3a-a726-266aebe08c93"/>
</line>
</band>
</pageFooter>
<summary>
<band/>
</summary>
</jasperReport>
答案 0 :(得分:0)
解决方案是在mysql的配置文件my.cnf
中跳过网络注释答案 1 :(得分:0)
我不确定是否是相同的情况,但我在处理相同的错误数小时后才注意到我在将其发送到报告之前关闭了连接