Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number Format Exception

 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone fine the exception with the Integers? I know where it is at, just can't find out how it is happening

Exception:

Database Query


Servlet:


JSP:

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only place where you cast something to an Integer is here:

And as the message says, what you're getting from the list is a String and you can't cast that to an Integer.

Perhaps this instead?
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What value is being returned by the getParameter call? If you do a System.out.println(request.getParameter("selection")), I have a feeling that it will be a value that does not convert directly to an int.
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
returns 1 for parameter call "selection".

line 68 returns "test" which is def not a number. Got to figure this out where the problem lies. The database is correct for that field though
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this is the problem causing your issue but you may wish to update your query to not use select * or using positional index to retrieve values from a ResultSet. I have seen way too many maintenance issues come out of this practice.
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike for your time

I just figured it out. It had the positional index numbers off trying to retrieve the values from the resultset. I'll go back and cleanup the query and use column names vs index.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic