我需要使用 iReport 生成报告,并且我正在尝试从 2 个不同的数据库中获取数据。我关注了这篇文章(Bilal Siddiqui,JasperReports 3.6 Development Cookbook 的作者)。但我每次都收到以下错误。它单独工作正常但是当我使用子报告时它开始给我错误。
主报告:-
<?xml version="1.0" encoding="UTF-8"?>
<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="MasterReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="projectName" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\rEPORTS\\"]]></defaultValueExpression>
</parameter>
<parameter name="connectionParam" class="java.sql.Connection" isForPrompting="false">
<defaultValueExpression><![CDATA[java.sql.DriverManager.getConnection("jdbc:mysql://localhost/liferay_6.0.6", "root", "root")]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[QUERY]]>
</queryString>
<field name="EMAIL" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="32" splitType="Stretch">
<staticText>
<reportElement x="0" y="2" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[EMAIL]]></text>
</staticText>
<staticText>
<reportElement x="126" y="2" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Work Station Name]]></text>
</staticText>
<staticText>
<reportElement x="260" y="2" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Work Station Type]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="100" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{EMAIL}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="271" y="0" width="200" height="100"/>
<subreportParameter name="emailAddress">
<subreportParameterExpression><![CDATA[$F{EMAIL}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{connectionParam}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "WorkstationSubReport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
错误填充打印...错误评估表达式:源文本:java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/liferay_6.0.6","root","root")
net.sf.jasperreports.engine.fill.JRExpressionEvalException:评估表达式时出错:源文本:java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/liferay_6.0.6","root","root" )