aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 102
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: 10905
    
  12

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: 102
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: 24166
    
  30

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: 102
Thanks for your suggestion. I will look for the java.sql.PreparedStatement soon.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help to resolve SQL command not properly ended issue in servlet
 
Similar Threads
iBatis and Parameter Map
What are the joins in Hibernate ?
getting List values out of hibernate query
how to send multiple data in a table in a mail application?
Right Outer Join in Oracle