File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes numeric overflow error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "numeric overflow error" Watch "numeric overflow error" New topic
Author

numeric overflow error

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
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 !


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Please post part of the log file showing the exact error.


My Blog: Down Home Country Coding with Scott Selikoff
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30916
    
158

Niranjan,
This is the correct forum. How large a value are you looking at? What database?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
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

Joined: Oct 16, 2005
Posts: 1277
any thought guys ?
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
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

Joined: Oct 16, 2005
Posts: 1277
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

Joined: Oct 16, 2005
Posts: 1277
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

Joined: Oct 16, 2005
Posts: 1277
any thought guys ?
any one of you has something more to tell ?
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
any more thoughts ?
A knibbs
Ranch Hand

Joined: Aug 23, 2006
Posts: 158
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

Joined: Dec 28, 2006
Posts: 893
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


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: numeric overflow error