Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

SQLException on column name  RSS feed

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!