aspose file tools
The moose likes JDBC and Relational Databases and the fly likes problem with syntax for SQL statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem with syntax for SQL statement" Watch "problem with syntax for SQL statement" New topic
Author

problem with syntax for SQL statement

Rob Petterson
Ranch Hand

Joined: Jan 23, 2002
Posts: 149
The method below is used as part of a search facility for my web site. I'm getting this error message:
org.apache.jasper.JasperException: Column not found, message from server: "Unknown column 'origin' in 'where clause'"

This is my code for the method:


Country and Type are defined as columns within the exsisting table within the DB.
Any ideas?
[ May 03, 2003: Message edited by: Rob Petterson ]

Rob Petterson
SCJP
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Try this instead:

String literals need to be single quoted. If you would be using a PreparedStatement, then you would not use the single quotes but with a regular Statement, you must.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Irene Loos
Ranch Hand

Joined: Apr 15, 2002
Posts: 78
Actually you have 2 errors in your SQL statement. Since origin, and coinType are parameters, try this:

[ May 03, 2003: Message edited by: Irene Loos ]

Irene Loos
Rob Petterson
Ranch Hand

Joined: Jan 23, 2002
Posts: 149
Thanks Lasse and Irene for you're help. You were right Irene, there were a couple of mistakes in my syntax. You wouldn't believe how long I spent yesterday trying to figure it out! It works fine now. I've got one more of those methods to overload for a more complex search query, so at least now I've got a fair shot at getting it to work with your previous help. Thanks again.
[ May 04, 2003: Message edited by: Rob Petterson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with syntax for SQL statement