Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java.sql.SQLException invalid indentifier exception

 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or even better, use PreparedStatement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic