permaculture playing cards*
The moose likes Java in General and the fly likes Please help to resolve SQL command not properly ended issue in servlet 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 » Java » Java in General
Bookmark "Please help to resolve SQL command not properly ended issue in servlet" Watch "Please help to resolve SQL command not properly ended issue in servlet" New topic
Author

Please help to resolve SQL command not properly ended issue in servlet

Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
I am using this select statement in java servlet and trying to execute it. But I am getting "SQL command not properly ended" error message in the console. But when I can successfully run this select query in the TOAD editor. I would appreciate if someone can help me to resolve this issue. Thanks..

Select statement in servlet:

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

This may be a dumb suggestion, but do you need a space on line 17 between the single quote and the "AND"?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
Actually you are right. This is a very good suggestion and it worked. I put spaces where the query appending and removed the single quote. It is working now. Thank you vary much for your suggestion. I really appreciate your help.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Now that your code is working, I hope you'll take a few minutes to improve it. This quoting problem wouldn't have happened -- and your code would be far more secure -- if you used java.sql.PreparedStatement . Go check it out!


[Jess in Action][AskingGoodQuestions]
Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
Thanks for your suggestion. I will look for the java.sql.PreparedStatement soon.
 
wood burning stoves
 
subject: Please help to resolve SQL command not properly ended issue in servlet
 
Similar Threads
getting List values out of hibernate query
What are the joins in Hibernate ?
Right Outer Join in Oracle
how to send multiple data in a table in a mail application?
iBatis and Parameter Map