how to give dataadaptor in jasper report

I have created a .jrxml file using iReport eclipse plugin. It takes json as an input. I have created jsonDataAdaptor inside the eclipse to export the report. Now I want to do the same using java, not iReport.

I have a .jrxml file and i am compiling the file using: JasperCompileManager.compileReportToFile

In the .jrxml file I have created some fields for the json and have used in textField.

 <field name="username" class="java.lang.String">
            <fieldDescription><![CDATA[username]]></fieldDescription>
        </field>
        <field name="pwd" class="java.lang.String">
            <fieldDescription><![CDATA[pwd]]></fieldDescription>
        </field>

I am having the username and pwd's in the test.json that is placed in my local drive in the same path as the .jrxml file.

My dataAdapter(in the same folder as .jrxml file):

<?xml version="1.0" encoding="UTF-8" ?>
<jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl">
<name>jsonDataAdaptor</name>
<fileName>C:\test\test.json</fileName>
<useConnection>false</useConnection>
<timeZone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    dirty="false" DSTSavings="0" raw-offset="19800000"
    xsi:type="java:sun.util.calendar.ZoneInfo">
    <ID>Asia/Calcutta</ID>
    <display-name>India Standard Time</display-name>
</timeZone>
<locale country="US" language="en" />
<selectExpression></selectExpression>
<datePattern></datePattern>
<numberPattern></numberPattern>
</jsonDataAdapter>

The problem is, when I am exporting the same into html I am getting values as null.

Answers


Here is the link for jasper datasource adapter.


Need Your Help

How can I get python in the command prompt on Windows?

python windows command-line command-prompt

I have just installed Python on my Windows 7. I thought that after that I will be able to run python on the command prompt but it is not the case. After the installation I also found out that I can...