• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQLException on column name

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

In my database I have a table named PROSPECTS. One of the fields in that table is STATE_PROVINCE.

I have a method named getProspectInfo(...) which is supposed to return all the data on a given individual including the STATE_PROVINCE.

My SQL statement reads like this:
SELECT FIRSTNAME,LASTNAME,COMPANY,ADDRESS1,ADDRESS2,CITY,STATE_PROVINCE,COUNTRY,ZIP_PCODE,PHONE,EMAIL_ADDRESS FROM PROSPECTS WHERE ID=14;

However, in my method when I call

String temp = resultSet.getString("STATE_PR0VINCE");

I keep getting an SQLException that states it cannot find the column named STATE_PROVINCE. It doesn't have a problem with any of the other columns. What gives? STATE_PROVINCE DOES EXIST in the the PROSPECTS table! Why is it giving me such a hard time?

Here's the actual readout:
java.sql.SQLException: Column 'STATE_PR0VINCE' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2316)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1822)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at mvcs.ManagerModel.getProspectInfo(ManagerModel.java:2442)

Please advise,

Alan
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might wanna make sure that its O and not 0 (zero)

The statement that you have mentioned has a 0 (zero) in the word PROVINCE instead of 'O'. I am assuming you ran it with a 0 (zero) since the error stack trace also has a 0 (zero) in it


String temp = resultSet.getString("STATE_PR0VINCE");

Here's the actual readout:
java.sql.SQLException: Column 'STATE_PR0VINCE' not found.
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2316)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1822)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at mvcs.ManagerModel.getProspectInfo(ManagerModel.java:2442)


[ December 19, 2006: Message edited by: Russell Peters ]
 
Alan Shiers
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Damned if you're right! I stared at that thing for more than an hour trying to figure out what the problem was. I just couldn't see it!

I guess all I needed was an extra pair of eyes to help figure it out.

Thanks
 
Screaming fools! It's nothing more than a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic