Jump to content

JXML without queryString empty?


edu-de

Recommended Posts

Hello,

I have two jrxml files which should only display a static text "Report Title". The only difference between them is the query string:

with query string:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 --><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="myReport"              pageWidth="842" pageHeight="595" orientation="Landscape"              columnWidth="744"              leftMargin="56" rightMargin="42"              topMargin="42" bottomMargin="42"              uuid="d532c1f1-3e7b-435c-8633-998b6d336727">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <property name="com.jaspersoft.studio.data.sql.tables"    value=""/>    <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="171"/>    <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="822"/>    <property name="com.jaspersoft.studio.unit.pageHeight"    value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageWidth"     value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnWidth"   value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>    <queryString>        <![CDATA[select 1]]>    </queryString>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band height="46" splitType="Stretch">            <staticText>                <reportElement mode="Transparent" x="0" y="10" width="496" height="21"                               uuid="fad5deb0-680c-4a56-a6b6-f9792ef1527a"/>                <text><![CDATA[Report Title]]></text>            </staticText>        </band>    </title></jasperReport>[/code]

without query string:

just delete this:

<queryString><![CDATA[select 1]]></queryString>[/code]

Both files are identical, their only difference is the queryString tag.

When running the reports in Jaspersoft Studio, both reports run correctly and I see "Report Title" on both reports.

When running them from java, I only see "Report Title" in the report with queryString. In the report without queryString I only see a blank page. How can this be ?

The java program to test:

import java.sql.Connection;import java.sql.DriverManager;import java.util.HashMap; import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint; public class JasperGenerator {    public static void main(String[] args) {        // System.out.println("Usage: ReportGenerator ....");         try {            System.out.println("Start ....");            // Get jasper report            String jrxmlFileName = "withoutQuery.jrxml";            String jasperFileName = "withoutQuery.jasper";            String pdfFileName = "withoutQuery.pdf";             JasperCompileManager.compileReportToFile(jrxmlFileName, jasperFileName);             String dbUrl = "jdbcURL";            String dbDriver = "jdbcDriver"; // for example            String dbUname = "username";            String dbPwd = "password";             // Load the JDBC driver            Class.forName(dbDriver);            // Get the connection            Connection conn = DriverManager.getConnection(dbUrl, dbUname, dbPwd);             // Create arguments            HashMap hm = new HashMap();             // Generate jasper print            JasperPrint jprint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conn);             // Export pdf file            JasperExportManager.exportReportToPdfFile(jprint, pdfFileName);             System.out.println("Done exporting reports to pdf");         } catch (Exception e) {            System.out.print("Exception" + e);        }    }}[/code]

I tested with the latest jasperreports library 6.6.0.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...