This content has been marked as final. Show 6 replies
How is that question related to Java jdbc? What is your query, what datatypes? Is getInt the wrong method?
Yes. This is related to JDBC. while retrieving data from DB am getting in this error.
Ok, I'm still waiting for the three other answers.
And just one more...what is the actual number you are trying to retrieve into an int?
Because that error says to me "it's too big".
This may be a confusion between the DBMS 'integer' column, which in Oracle can store a number
much bigger than a Java int, and the JDBC code. Doing a getBigDecimal() will get any numeric
That 'getInt' method returns a Java 'int'. It will attempt to convert the actual data value in the result set column to an int.
If the value is too large, too small or isn't even numeric you will get an exception.
Isolate the problem (e.g. by debugging) to the row giving the exception and then examine the actual data value. If you are using NetBeans (or other) you can use the 'getString' method to see what the value is that is causing the problem.
The actual 'solution' to the problem depends on your database, the table column definition and the business rules being implemented.
You table could contain 'dirty' data and contain values larger than you want to be stored.
Or your actual data could be correct and you are just using 'getInt' instead of 'getBigDecimal' or other method to get the value.
Don't apply a 'solution' until you actually know what the problem is and the proper solution to implement.