This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

numeric overflow error

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am not sure whether this is the right forum to ask this. but still, i am dropping my query here -

i have a database procedure that takes 3 input parameters and give one output parameter. this output parameter is being registered (of course before i execute the procedure call ) as -

registerOutParameter(String parameterName, int sqlType)

the sqlType that i am using is Types.INTEGER.

the parameterName is the output of the stored procedure, which in my case is some sort of ID, and i think its too large in magnitude, to be
(registered using) / (accomodated into) the Types.INTEGER, and i am getting a Numeric overflow error in the log file.

please help me out

the out parameter is read using getInteger ( dont remember exactly )

i have done a bit of googling for this, and the conclusion was to use
getString instead of getInteger.

is there anything more in the Types class that can accomodate larger values (like my id ) ?

thanks in advance !
 
Scott Selikoff
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post part of the log file showing the exact error.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niranjan,
This is the correct forum. How large a value are you looking at? What database?
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just had a sysout in the code and i got 1037459 as the output.
is it OK to be registerd as

registerOutParameter(4, Types.INTEGER);

the completed ode snippet is -

query.append("CALL some_procedure_name(?,?,?,?)");

statement = connection.prepareCall(query.toString());
statement.setLong(1, directDebitKey.getKey().longValue());
statement.setInt(2, status.getCode());
statement.setString(3, userContext.getUser().getUserName());
statement.registerOutParameter(4, Types.INTEGER); //we need change here ?
statement.executeQuery();
System.out.println("after procedure call @@@@@@@@@" + statement.getLong(4));
return new Long(statement.getLong(4)); //gives error


more ever the problem is, i dont get this error on the local environment
but i get a error on the box on whin this app is deployed.

both are pointing to the same database thats a 10g !
[ March 12, 2007: Message edited by: Niranjan Deshpande ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any thought guys ?
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see you registered the out parameter as INTEGER and reading the value as long. Can you try with getInt? Maybe driver is trying to parse 8 bytes rather than 4 bytes resulting in the overflow.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the INTEGER and getLong combination is working in all other classes
its throwing error only for a specific browser's use cas ( in a particular data access class )

the out parameter that i got from the procedure is in the range of 10 lakhs

e.g 1037459 etc !

also.... will it be of any help if i use Types.BIGINT or Types.NUMERIC to register the parameter ?

the database field is NUMERIC(20) in the table..
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are using oracle 10g (just migrated from 9i to 10g)
and yes we migrated from WSAD4 to 5..

so the migration changes have come into effect..

is this error related to that ?
[ March 06, 2007: Message edited by: Niranjan Deshpande ]
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any thought guys ?
any one of you has something more to tell ?
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any more thoughts ?
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using the int part instead of a long ? I know you said it works in all other cases but that isn't the point. When fixing bugs you concentrate on what doesn't work.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could define the output parameter of the type Decimal or Numeric and use the method getBigDecimal for getting the value.

Then you can return a long value by the function BIGDECIMAL.longvalue()

I hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic