This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Java.sql.SQLException invalid indentifier exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java.sql.SQLException invalid indentifier exception" Watch "Java.sql.SQLException invalid indentifier exception" New topic
Author

Java.sql.SQLException invalid indentifier exception

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Hey all,

Please can you help me?I am getting the following error.

java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: "CUST001": invalid identifier


I am working on a monthly billing system for general stores. I enter the ITEMID and click the button. The ITEMID is stored in a variable and searched for item details from the ITEMS table which are then entered into PURCHASE table along with a previously retrieved CUSTOMERID in this case the customerid is CUST001.

Following is the code of the button click event.
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Hi,
String query1 = "Select * from items where itemcode =" +itemcodepass;


I suppose above statement is the root cause.
All you need to do is, try putting itemcodepass in quotes like:
String query1 = "Select * from items where itemcode =" + "\' ''+ itemcodepass + "\' '';

Thanks,
Ashwini Kashyap


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

Or even better, use PreparedStatement.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java.sql.SQLException invalid indentifier exception
 
Similar Threads
How to get a system date and store it in a variable?
Is there a datatype that allows me to store more than one item at a time , in a column in a row?
Jtextbox entering values into db(concerns with datatype)
Calling a button to perform add function into database. Please help with the code.
Error in Vector<> .while using netbeans