2
votes

I am using iReport 4.5.1 and i need to get the date from the oracle.sql.TIMESTAMP.
Inside the expression i tried with these two:

  1. $F{DELIVERY_DATE}.dateValue()
  2. $F{DELIVERY_DATE}.timestampValue()

but i am getting the same runtime error

JasperReport Error:

Error filling print... Error evaluating expression :      Source text : $F{DELIVERY_DATE}.dateValue() net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :      Source text : $F{DELIVERY_DATE}.dateValue()      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)      at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:876)      at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:421)      at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:406)      at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)      at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:434)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:398)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:259)      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)      at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:879)      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)  Caused by: java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to oracle.sql.TIMESTAMP      at Liste_colisage_par_rack_1439547941026_908820.evaluate(Liste_colisage_par_rack_1439547941026_908820:438)      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190)      ... 19 more

Thanks in advance

Anand

3

3 Answers

3
votes

Try this

In iReport, JasperReport File's XML file :

<queryString>
        <![CDATA[*your query*]]>
</queryString>
    <field name="DELIVERY_DATE" class="oracle.sql.TIMESTAMP"/>
    <field name="NAME" class="java.lang.String"/>

Try changing it too

 <queryString>
        <![CDATA[*your query*]]>
</queryString>
    <field name="DELIVERY_DATE" class="java.util.Date"/>
    <field name="NAME" class="java.lang.String"/>

You might be using the DataType oracle.sql.TIMESTAMP from Oracle Database to JasperReport directly when you are modifying Report Query in JasperReport.

i.e. Try changing oracle.sql.TIMESTAMP to java.util.Date in your jasperReport file and use the DELIVERY_DATE Field in Jasper Report directly

NOTE:
You may have to repeatedly modify the dataType of DELIVERY_DATE to java.util.Date in XML of JasperReport if you modify the query in the Report Query section of JasperReport

0
votes

for those that were led to this page searching for "oracle.sql.TIMESTAMP cannot be cast to oracle.sql.TIMESTAMP" search query - this might be occuring in other cases besides Jasper - for instance, for me, I was using my project on tomcat with ojdbc6.jar both loaded in my webapp, and in Tomcat /lib folder. The solution was to specify ojdbc6 library with "provided" scope in Maven dependencies of my webapp.

the root of the problem is given here