Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Number Format Exception

 
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:

 
Marshal
Posts: 25837
69
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?
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • 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
Oracle Fedora Java
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic