rbalasus Posted August 19, 2009 Share Posted August 19, 2009 ireport query: cannot cast int to integerHello, I try to create my first report with ireport.Now I see the following problem. I want to use a query which gets a value through a paramaterselect Value1 from Table1 where ID=$P(ID)the value in the query should be an integer, how can I avoid this problem?Regards Randolf Balasus Post Edited by rbalasus at 08/21/2009 05:45 Link to comment Share on other sites More sharing options...
rodriguezum Posted August 19, 2009 Share Posted August 19, 2009 didn't quite understood what was your problem, but for casting in to an integer just do ' new Integer(int) ' , i use java for language Link to comment Share on other sites More sharing options...
rbalasus Posted August 19, 2009 Author Share Posted August 19, 2009 Hello, thanx for your answer. My problem is very simple: the report is crashing because of this error message. I just only want to start the report with one parameter, and i want to use this parameter in my query. The datatype in the query seems to be "int" and in ireport i can only choose integer, these both types seems not to correspond, and i have this error above... Thanx for any answer Link to comment Share on other sites More sharing options...
svenn Posted August 19, 2009 Share Posted August 19, 2009 Post your JRXML file and we can take a look at it. Link to comment Share on other sites More sharing options...
rbalasus Posted August 19, 2009 Author Share Posted August 19, 2009 Code:Hello attached is a very simple example with this error, I want to query against a table with column type of int. There you can see the error in ireport. Thanx in advance, Randolf Balasus Link to comment Share on other sites More sharing options...
svenn Posted August 20, 2009 Share Posted August 20, 2009 Which version of iReports are you using?The jrxml that you posted does not have a parameter so it's hard to figure out what you issue is. Link to comment Share on other sites More sharing options...
rbalasus Posted August 20, 2009 Author Share Posted August 20, 2009 Hello, thanx for your answer.I use iReprot 3.5.2 What do you mean by: The Report has no Paramater?When I look into this .jrxml file, then I found this Line " <parameter name="ID" class="java.lang.String">"What should I say: there is a Parameter named "ID", here in this example it is from type String, I have tested with the Parameter type Int, in both cases I got this error: Cannot cast int to integer (int is the type in the java reporting software, and integer is the type from the tablecolumn in mysql) Greetings Randolf Balasus Link to comment Share on other sites More sharing options...
dtrobert Posted August 20, 2009 Share Posted August 20, 2009 I think you might try <parameter name="ID" class="java.lang.Integer"> <defaultValueExpression><![CDATA[new java.lang.Integer(2)]]></defaultValueExpression> Are you passing this parameter in from a parent report? Link to comment Share on other sites More sharing options...
svenn Posted August 20, 2009 Share Posted August 20, 2009 That's what I though. I can't read your file correctly as we're still on 1.3.3. Hopefully someone will come along to answer your question that is more familiar with 3.5. Link to comment Share on other sites More sharing options...
rbalasus Posted August 21, 2009 Author Share Posted August 21, 2009 I was recreating this report and it was working. I am not 100% sure what exactly triggers this error message.in the query was a typo instead of select value1 from mbus where ID = $P{ID} I wroteselect value1 from mbus where $P{ID} = ID(column and parametername was not in the right order)In the new report I was using different names for Column an Parameter, maybe this is a problem too.I was not using my parameter in SubDataset then in the mainquery.And i was working in this order:- creating report parameter, compiling testing- using in queryBut now all is working as expected.thanx for your help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now