Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NumberFormatException: For input string: "12122009100"

 
Nagaraju Pee
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want ti insert a number 12122009100 into a table called EMPDATA which has a column emp_val number(16,0) with preparedstatement.

Here i'm using getters and setters.




The main class code snippet is as follows....



while executing the above class i'm getting NumberFormatException.
could anybody please assist me why i'm getting this exception

thanks







 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a long instead of an int.
 
Nagaraju Pee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still i'm getting the same exception even though i changed it to long
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show me your code.
 
Nagaraju Pee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception got resolved by replacing Integer.parseInt() with Double.parseDouble()
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception may be resolved, but are you certain it's doing the right thing? If it's not possible to pass a parameter to a "setInt" method using the result of parsing in integer, then maybe it actually isn't an integer? In which case passing a Double would just mask the problem. Make sure the DB data type can handle all values that Double.parseDouble returns for all input values that may get passed into it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why doesn't it work with long ? Please show me your code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic