• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be a dumb suggestion, but do you need a space on line 17 between the single quote and the "AND"?

 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion. I will look for the java.sql.PreparedStatement soon.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic