File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equalizing a variable in an sql statement

 
Keshini Weerasuriya
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

I'm trying to equal an ID which is taken as user input in an sql staement as below..

int answer = Integer.parseInt(mainMenu.client);
ResultSet rs = st.executeQuery("select * from Client where CliId = answer ");

Give the error, java.sql.SQLException: ORA-00904: invalid column name
Pls help.. Tnx..
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the column name you listed was not found in the table. I'm not sure, but it may be case sensitive.
 
Mani Ram
Ranch Hand
Posts: 1140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that you have included the 'answer' variable with in the quotes. So the query that will be executed in the database will be


The proper way to build the query is


Another way is to use a PreparedStatement
 
Keshini Weerasuriya
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tnx Mani Ram.. Your method works.........
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic