Cfjasperreport

I am using the <cfjasperreort> tag but I can’t find any examples of how to configure it to access data from a mySQL datasource. Does anyone know how to do this?

The tag will gladly accept a query attribute, e.g.:

<jr:jasperreport
           jrxml="#template#"
           exportfile="#filename#"
           query="#qData#"
           reportparams="#reportparams#"
           forceDownload="false"
           exporttype="pdf"
      />

I am using:

<jr:jasperreport jrxml=“C:\lucee\webapps\ROOT\simple_blue.jrxml”

query=“select id, name, countrycode, district, population from cityw here 1=1”
driver = ‘mysql’
username = ‘super’
password = ‘XXXXXXXX’
host = ‘localhost’
database = ‘world’
port = ‘3306’
jdbc_driver = ‘com.mysql.jdbc.Driver’
jdbc_url = ‘jdbc:mysql://localhost/world’
jdbc_dir = ‘C:\jasperstarter\jdbc’
exportfile=“C:\lucee\webapps\ROOT\simple_blue.pdf”
exporttype=“pdf”

/>

but it throws a:

The serializer class ‘org.apache.xml.serializer.ToXMLStream’ does not implement org.xml.sax.ContentHandler.

C:\lucee\webapps\ROOT\cfjasperreport\tags\cfjasperreport\cfc\jasperreport.cfc: line 293
291: var classpath = system.getProperty(“java.class.path”);
292: var daTitle = daJRXML.jasperReport.xmlAttributes.name;
293: var daXM = toString(daJRXML);
294: var xmlBuffer = getLibraryLoader().create(“java.lang.String”).init(daXM).getBytes();
295: var xmlInputStream = getLibraryLoader().create(“java.io.ByteArrayInputStream”).init(xmlBuffer);

It appears I have a mismatch in my jar files. Any ideas how to fix this?

Ok, fixed my jars but now I get the report but no detail, Just the headers.

Ok, working now with:

<jr:jasperreport jrxml=“C:\lucee\webapps\ROOT\simple_blue.jrxml”

query="select id, name, countrycode, district, population from city" 
datasource="world"
exportfile="C:\lucee\webapps\ROOT\simple_blue.pdf" 
exporttype="pdf"

/>

Jasper expects the contents of the query attribute to be a ready-to-use query object (sorry, wasn’t clear in my previous post) like this:

<cfquery name="qData" datasource="world">
  select id, name, countrycode, district, population from city
</cfquery>
<jr:jasperreport
           jrxml="#template#"
           exportfile="#filename#"
           query="#qData#"
           reportparams="#reportparams#"
           forceDownload="false"
           exporttype="pdf"
      />

Hope this helps.

Hi Lutz,

Very clear now, thanks very much for the help.

Jim