This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQLException on column name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException on column name" Watch "SQLException on column name" New topic
Author

SQLException on column name

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
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
Russell Peters
Ranch Hand

Joined: Jan 25, 2006
Posts: 50
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 ]

SCJP 1.4
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException on column name
 
Similar Threads
Hit ORA-00060: deadlock detected while waiting
key word to sort from 0 to
Runtime Creating Tables
Hibernate: Problem getting a simple list
properties file with SQL statements