Jump to content
JasperReports Library 7.0 is now available ×

Problems WIth Numeric Fields


2005 IR Help

Recommended Posts

By: Edward V. Berard - edberard

Problems WIth Numeric Fields

2005-05-31 04:57

When confronted with a database table with all numeric fields, i.e., no string

fields, it may be impossible to produce a report. It does not look as if

iReport is directly to blame however.

 

In attempting to produce a report for such a table, I got 3 nasty compilation errors of the form:

 

net.sf.jasperreports.engine.JRException ...

 

1. Cannot cast from Integer to String

value =

(java.lang.String)(((java.lang.Integer)field_XXX_YYY.getValue())))

...

 

-- Ed

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Problems WIth Numeric Fields

2005-05-31 07:49

 

you have to change the type set for your textfield.

 

Giulio

 

 

 

 

By: nick - nickpellow

RE: Problems WIth Numeric Fields

2005-06-17 03:07

Is it possible to set the default mapping iREPORTS uses when mapping fields from a database to the java objects JasperReports needs?

 

For example, currently all NUMBER fields in my Oracle database get mapped to java.lang.Doubles. I would like to change this to java.lang.Long.

 

 

 

 

By: J. Brett Howell - jbretthowell

RE: Problems WIth Numeric Fields

2005-06-20 12:26

iReport defaults to Double when "reading" the fields returned from your query expression, but you can change those data types in the XML if you desire. For instance, rather than using a Double, if one needs to store the value in a BigDecimal, import the BigDecimal class:

<import value="java.math.BigDecimal" />

and change the class for the field accordingly:

<field name="chargeAmount" class="java.math.BigDecimal"/>

The only downside is that if one uses Datasource>Report Query feature of iReport again later, these changes will be overwritten with the iReport default (double), so be careful.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...