This week's book giveaways are in the Angular and TypeScript and Web Services forums.
We're giving away four copies each of Programming with Types and The Design of Web APIs and have the authors on-line!
See this thread and this one for details.
Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

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: 24843
60
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.

 
Crusading Chameleon likes the size of this ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!