Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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
 
It's just a flesh wound! Or a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!