0

I have very simple select query in my dataset and Query dialog. When I run this query I get 2 times more data fields as there are in the database! And my report book has more pages than the report itself, which I guess happens because of the redundant data. The same query delivers 3 data fields even without distinct and in Jaspersoft 6 data fields!

select distinct * 
from KennzahlReferenz2015_QIBericht, Images
where LB_ID = 62
and KN_OffiziellGruppe =3
and IMG_ID = 1

And here is the source code of report:

<?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="direktRechrDV" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d12b4217-cf22-4ec4-857b-9cb1b2b406a8">
<property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>

<scriptlet name="moveTOC" class="testProjektIman.toc.MoveTOC">
    <scriptletDescription><![CDATA[moves toc to first page]]>  </scriptletDescription>
</scriptlet>
<parameter name="LB_ID" class="java.lang.Integer">
    <parameterDescription><![CDATA[ID des Leistungsbereiches]]>  </parameterDescription>
    <defaultValueExpression><![CDATA[62]]></defaultValueExpression>
</parameter>
<parameter name="KN_OffeziellGruppe" class="java.lang.Integer">
    <defaultValueExpression><![CDATA[3]]></defaultValueExpression>
</parameter>
<parameter name="toc" class="java.lang.StringBuilder"  isForPrompting="false">
    <defaultValueExpression><![CDATA[new StringBuilder()]]></defaultValueExpression>
</parameter>
    <parameter name="idName" class="java.lang.String" isForPrompting="false"/>
    <queryString>
    <![CDATA[select distinct * 
from KennzahlReferenz2015_QIBericht, Images
where
LB_ID = $P{LB_ID}  
and 
KN_OffiziellGruppe =$P{KN_OffeziellGruppe}
and IMG_ID = 1]]>
</queryString>
<field name="QI_Praefix" class="java.lang.String"/>
<!--
.
.other fields
. -->
<field name="Image" class="java.awt.Image"/>
<variable name="someVar" class="java.lang.String">
    <variableExpression><![CDATA[$V{someVar}]]></variableExpression>
</variable>
<variable name="tocVar" class="java.lang.String">
    <variableExpression><![CDATA[$V{tocVar}]]></variableExpression>
</variable>
<group name="id" isStartNewPage="true" isReprintHeaderOnEachPage="true" keepTogether="true">
    <groupExpression><![CDATA[$F{KN_Id}]]></groupExpression>
    <groupFooter>
        <band splitType="Immediate">
        </band>
    </groupFooter>
</group>
<group name="LBgroup" isReprintHeaderOnEachPage="true" keepTogether="true">
    <groupExpression><![CDATA[$F{LB_ID}]]></groupExpression>
    <groupFooter>
        <band splitType="Immediate"/>
    </groupFooter>
</group>
<pageHeader>
    <band height="62" splitType="Stretch">
        <staticText>
            <reportElement x="8" y="2" width="409" height="26" uuid="37a242c0-b352-42e1-b287-42350a5e2090"/>
            <textElement markup="html"/>
            <text><![CDATA[Statistische Basisprüfung - Auffälligkeitskriterien: Verstetigung und Vollzähligkeit 2015<br>]]></text>
        </staticText>
        <textField isStretchWithOverflow="true">
            <reportElement x="7" y="16" width="322" height="19" uuid="f28c3fc0-6d00-4437-a185-febccf94e91f"/>
            <textElement markup="none"/>
            <textFieldExpression><![CDATA[$F{idLb} +" - "+ $F{LB_LangBezeichnung}]]></textFieldExpression>
        </textField>
        <textField bookmarkLevel="1">
            <reportElement x="8" y="32" width="321" height="20" uuid="705007c1-4bfa-483a-a113-887cf7fd6488"/>
            <textFieldExpression><![CDATA[$F{KN_Id}+": "+$F{KN_BezeichnungAlleinstehendKurz}]]></textFieldExpression>
            <anchorNameExpression><![CDATA[$F{KN_Id}+":"+$F{nameAlleinstehend}]]></anchorNameExpression>
        </textField>
        <image hAlign="Center">
            <reportElement x="480" y="6" width="50" height="50" uuid="3f5fe998-e94e-4280-af71-7f7163878156">
                <printWhenExpression><![CDATA[$F{IMG_ID} == 1]]></printWhenExpression>
            </reportElement>
            <imageExpression><![CDATA[$F{Image}]]></imageExpression>
        </image>
    </band>
</pageHeader>
<columnHeader>
    <band splitType="Stretch"/>
</columnHeader>
<detail>
    <band height="345">
        <printWhenExpression><![CDATA[new Boolean($V{id_COUNT}.intValue()==1)]]></printWhenExpression>
        <frame>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="8" y="40" width="292" height="220" uuid="55ca2869-dd02-48a5-a9bf-90b538ea22a6"/>
            <frame>
                <reportElement positionType="Float" x="0" y="0" width="280" height="21" printWhenGroupChanges="id" uuid="255952d3-ed97-4615-926f-e7e89560d64a"/>
                <textField isStretchWithOverflow="true">
                    <reportElement key="" positionType="Float" x="99" y="0" width="181" height="21" printWhenGroupChanges="id" uuid="83851dcf-a0b2-44df-9117-0c5487b16260">
                        <property name="net.sf.jasperreports.export.json.path" value="AK.id"/>
                        <property name="net.sf.jasperreports.export.json.repeat.value" value="true"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{KN_Id}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="99" height="21" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="168d731e-09c0-4b1e-ac6f-c86168fe1286">
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[AK_ID]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="21" width="280" height="21" printWhenGroupChanges="id" uuid="0879346c-a263-431d-8e2d-8d2a1cd0e67c"/>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="99" height="21" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="75c8f9aa-47d6-4869-b8b2-a16ca58e11db"/>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Präfix]]></text>
                </staticText>
                <textField isStretchWithOverflow="true">
                    <reportElement key="" positionType="Float" x="99" y="0" width="181" height="21" printWhenGroupChanges="id" uuid="f38998f8-8dc7-4ccc-8066-0cfe5e7ab876">
                        <property name="net.sf.jasperreports.export.json.path" value="qi.praefix"/>
                        <property name="net.sf.jasperreports.export.json.repeat.value" value="true"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{QI_Praefix}]]></textFieldExpression>
                </textField>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="42" width="280" height="30" printWhenGroupChanges="id" uuid="92186cbd-4a98-4c6e-9b51-0dfe52d5ff21"/>
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="99" y="0" width="181" height="30" printWhenGroupChanges="id" uuid="4818fc44-cde3-40ed-8d77-a6dd71b89f79">
                        <property name="net.sf.jasperreports.export.json.path" value="begruendung.relevanz"/>
                        <property name="net.sf.jasperreports.export.json.repeat.value" value="true"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement markup="html">
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA["<b>Relevanz</b><br>" +($F{KN_Zusatzinfo_DV_Relevanz} !=null ? $F{KN_Zusatzinfo_DV_Relevanz} : "-")+"<br><b>Hypothese</b><br>" + ($F{KN_Zusatzinfo_DV_Hypothese} !=null ? $F{KN_Zusatzinfo_DV_Hypothese}: "-")]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="99" height="30" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="a93eb1cf-015c-442a-afac-68c7f9a30cb5">
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph lineSpacing="Single"/>
                    </textElement>
                    <text><![CDATA[Begründung für die Auswahl]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="72" width="280" height="27" printWhenGroupChanges="id" uuid="91d6b54a-bcd4-4737-8208-7dcd9e388ea4">
                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                </reportElement>
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="99" y="0" width="181" height="27" printWhenGroupChanges="id" uuid="883db6cf-5cc6-4e32-a4cd-54bdf86b97df">
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement rotation="None">
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[($F{KN_Zusatzinfo_DV_Indikatorbezug} !=null ? $F{KN_Zusatzinfo_DV_Indikatorbezug} : "-")]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="-1" width="99" height="27" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="61373b56-22c7-4097-8da1-ebcd702bc410">
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Bezug zu anderen Indikatoren]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="99" width="280" height="27" printWhenGroupChanges="id" uuid="be213a60-4cd9-4f4a-972b-edfbf7b408c9"/>
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="99" y="0" width="181" height="27" printWhenGroupChanges="id" uuid="261644b6-bbdb-4528-9f25-7fb23e98bf99">
                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{bewertungsArtTypNameKurz}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="99" height="27" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="d338843f-2f88-4d1b-b355-e7757acacf8e">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Bewertungsart]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="127" width="280" height="27" printWhenGroupChanges="id" uuid="626fe004-8942-4655-8c64-4022728e65e9"/>
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="99" y="0" width="181" height="27" printWhenGroupChanges="id" uuid="3ea786ed-6ce2-4ce7-84af-b4b7d29cc3b7">
                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{mindesanzahlZaeler}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="-1" width="99" height="27" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="284779f8-692b-45b1-a535-62f1a4ce124b">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Mindestanzahl Zähler]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="154" width="280" height="27" uuid="f2f30758-914b-4990-b508-644cabb06f3f"/>
                <textField isStretchWithOverflow="true">
                    <reportElement positionType="Float" x="99" y="0" width="181" height="27" printWhenGroupChanges="id" uuid="77c50b2a-a9ec-4225-8361-4daa6dc9d97e">
                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{KN_Vergleichbarkeit_Vorjahr}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="99" height="27" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="4f5650a6-9330-444b-bfec-0c1cd03d254f">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Vergleichbarkeit mit Vorjahr]]></text>
                </staticText>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="182" width="280" height="27" uuid="3a70786a-ab1b-4193-8087-bcf9f363116a"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                    <reportElement positionType="Float" x="99" y="-1" width="181" height="27" printWhenGroupChanges="id" uuid="0d48b38a-07e8-42e7-89e8-e0580651028e">
                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <paragraph leftIndent="1"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{mindesanzahlNenner}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="-1" width="99" height="27" printWhenGroupChanges="id" forecolor="#FFFFFF" backcolor="#005051" uuid="fc8232c6-dfb5-482a-9fef-a9ac1f75861a">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <text><![CDATA[Mindestanzahl Nenner]]></text>
                </staticText>
            </frame>
        </frame>
        <textField isStretchWithOverflow="true" hyperlinkType="" hyperlinkTarget="">
            <reportElement mode="Transparent" x="0" y="4" width="340" height="6" printWhenGroupChanges="id" uuid="56a6e5f3-fd57-436e-8acb-8dbc1acbb220">
                <printWhenExpression><![CDATA[1==0]]></printWhenExpression>
            </reportElement>
            <textElement markup="html"/>
            <textFieldExpression><![CDATA[$F{KN_Id}+":"+$F{nameAlleinstehend}]]></textFieldExpression>
            <hyperlinkReferenceExpression><![CDATA[]]></hyperlinkReferenceExpression>
        </textField>
        <staticText>
            <reportElement x="11" y="14" width="78" height="16" uuid="17d269d4-d7fa-44ef-8b00-d1abe0ecb92c"/>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Berechnung]]></text>
        </staticText>
    </band>
</detail>
<columnFooter>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</columnFooter>
<pageFooter>
    <band height="54" splitType="Stretch">
        <staticText>
            <reportElement x="0" y="20" width="410" height="20" uuid="0744ba3c-69d3-4220-b201-72dabdeb5038"/>
            <textElement>
                <font size="8"/>
            </textElement>
            <text><![CDATA[ins]]></text>
        </staticText>
        <textField evaluationTime="Master">
            <reportElement x="481" y="18" width="69" height="24" uuid="5789c6a7-2ca2-4ba9-bd13-1b56ddcb7091"/>
            <textFieldExpression><![CDATA["Seite "+$V{MASTER_CURRENT_PAGE}+" von"+$V{MASTER_TOTAL_PAGES}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
</jasperReport>

And here is the report book:

<?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="qidbReport" pageWidth="595" pageHeight="842" sectionType="Part" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" uuid="d2716064-8ae4-40cf-a575-33afba400e3a">
<property name="com.jaspersoft.studio.data.defaultdataadapter"  value="KennzahlReferenz2015_QIBericht"/>
<property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>
<property name="com.jaspersoft.studio.book.group.cover.header" value="Cover     and Table of Contents"/>
<property name="com.jaspersoft.studio.book.group.cover.footer" value="Backcover"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
    <![CDATA[select distinct KN_Id ,    "KennzahlReferenz2015_QIBericht"."nameAlleinstehend" , Image from "KennzahlReferenz2015_QIBericht", Images where LB_ID = 62
and "KN_OffiziellGruppe" =3 and IMG_ID = 1]]>
</queryString>
<field name="KN_Id" class="java.lang.Integer"/>
<field name="nameAlleinstehend" class="java.lang.String"/>
<field name="Image" class="java.awt.Image"/>
<group name="cover">
    <groupHeader>
        <part uuid="7aed05b9-1301-4a53-b47e-34289560bc0c">
            <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
                <subreportExpression><![CDATA["qidbReport_cover.jasper"]]></subreportExpression>
            </p:subreportPart>
        </part>
        <part evaluationTime="Report" uuid="56ab525c-754f-4f48-a52c-7cc23934be3d">
            <property name="net.sf.jasperreports.bookmarks.data.source.parameter" value="REPORT_DATA_SOURCE"/>
            <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
                <subreportExpression><![CDATA["qidbReport_toc.jasper"]]></subreportExpression>
            </p:subreportPart>
        </part>
    </groupHeader>
    <groupFooter>
        <part uuid="88decbbe-63ad-45cc-9e03-5dadc50004d5">
            <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
                <subreportExpression><![CDATA["qidbReport_backcover.jasper"]]></subreportExpression>
            </p:subreportPart>
        </part>
    </groupFooter>
</group>
<detail>
    <part uuid="fbf811eb-2c43-48b9-a88b-ae94453264df">
        <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
            <subreportParameter name="REPORT_CONNECTION">
                <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
            </subreportParameter>
            <subreportExpression><![CDATA["direktRechrDV.jasper"]]></subreportExpression>
        </p:subreportPart>
    </part>
</detail>
</jasperReport>

These are the outputs from JR and DB: Jasper:

JR

DB:

DB

Iman
  • 769
  • 1
  • 13
  • 51
  • Can't really understand what you are doing but I see "select * from "KennzahlReferenz2015_QIBericht" ,Images" in the source code of report. Is another query then what you believe executed? – Petter Friberg Jun 15 '16 at 07:22
  • I have tested the query against the database. There are only 3 fields there. – Iman Jun 15 '16 at 07:59
  • The "select * from "KennzahlReferenz2015_QIBericht" ,Images" query is for a table data set. I have deleted that one but still there are 2 times more data by running the query in JR – Iman Jun 15 '16 at 08:00
  • Could you add the output from the db query and from the report? Also, it seems that a `JOIN` is missing in the query. – tobi6 Jun 15 '16 at 09:07
  • I added screen shuts from both. I gave the parameters in JR manually to be sure that it is not the parameters problem some how. – Iman Jun 15 '16 at 10:36
  • @Iman It is looks like a magic. Maybe you are using different DB connections (schema/db)... – Alex K Jun 15 '16 at 11:31
  • @Iman Did you use the same user name for connection? – Alex K Jun 15 '16 at 11:33
  • No! I have created a different user name for jasper, since I could not manage connecting to the data base via windows authentication in jasper – Iman Jun 15 '16 at 11:41
  • @AlexK how can it make such an effect on data? I am connecting to the data base with one user name at a time! What am I missing here? – Iman Jun 15 '16 at 11:59
  • How are `KennzahlReferenz2015_QIBericht` and `Images` joined? Still seems to be a [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) to me. Try leaving `Images` out of the `select` just to check the amount of resulting rows. – tobi6 Jun 15 '16 at 13:12
  • Leaving Images mad no changes.The Image with IMG_ID = 1 should be read for all fields. Weird is that I get this behavior only in Jasperstudio and not in Database. – Iman Jun 15 '16 at 13:21
  • I am still not convinced that the `select *` is doing what you need. Try selecting just a few named fields in the Jasperstudio Query Designer (without `Images`). Images should be joined [like here](http://stackoverflow.com/questions/8567288/sql-server-inner-join-with-distinct). – tobi6 Jun 15 '16 at 13:48
  • I tried selecting only one field ( select KN_Id ...) without Images, but still there are exactly two times more data! Does Jasper caches data? – Iman Jun 15 '16 at 14:06
  • How does your `select` look like? Jasper usually doesn't cache the data. – tobi6 Jun 15 '16 at 15:30
  • As I have written in the question:select distinct * from KennzahlReferenz2015_QIBericht, Images where LB_ID = 62 and KN_OffiziellGruppe =3 and IMG_ID = 1 – Iman Jun 16 '16 at 06:11
  • @AlexK I changed the authentication. I use windows authentication to connect to DB. But still double data fields! – Iman Jun 16 '16 at 07:11
  • @Iman Did you check the report? Is the situation the same? – Alex K Jun 16 '16 at 07:15
  • I meant the small `select` without Images and the `KN_Id`, not the one we know already. Sorry for the confusion. – tobi6 Jun 16 '16 at 07:27
  • select distinct KN_Id from KennzahlReferenz2015_QIBericht where LB_ID = 62 and KN_OffiziellGruppe =3 which gives duplicate number of Ids as in DB – Iman Jun 16 '16 at 07:59
  • So if this statement doesn't work in Jasper Studio, the driver or the connection may be the culprit. You could try the user for Jasper in the MS SQL console. If that works, maybe the driver or the connection are flawed. – tobi6 Jun 16 '16 at 11:46
  • I have found the source of problem and updated the question. – Iman Jun 17 '16 at 06:18
  • 2
    @lman To make things easier to follow for later visitors, you can provide the answer to your question as opposing as to put the answer into the question. – tobi6 Jun 17 '16 at 07:30

1 Answers1

0

The problem is not because of the driver or source code. It happens when I add a report books. Then the wave book asks for a data source and query. When I write a query there, jasper adds those results to the ones from main report.

Iman
  • 769
  • 1
  • 13
  • 51