• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

numeric overflow error

 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
author & internet detective
Posts: 42165
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any thought guys ?
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any more thoughts ?
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic