aspose file tools*
The moose likes Beginning Java and the fly likes Number Format Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Number Format Exception" Watch "Number Format Exception" New topic
Author

Number Format Exception

Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
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
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

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

Joined: May 04, 2011
Posts: 144



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.


OCJP6, OCWCD5
Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
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

Joined: May 04, 2011
Posts: 144

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

Joined: Mar 11, 2011
Posts: 63
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number Format Exception