Bear Bibeault wrote:Your servlet shouldn't be generating the output. After it does the computations, it should forward to a JSP to create the display.
See this article for details on how to properly structure web applications.
Vishal Shaw wrote:
select Country_Name, 'y1964' from sadm where Series_Name= 'Agricultural machinery tractors' order by 'y1964' desc
Did you tried running theis exact query in your mysql directly? Also, is y1964 your column name? Then did you realized, that you have quotes around it
Vishal Shaw wrote:Hi,
Paul Clapham wrote:
Okay. You're a troll, then. No more answers from me.
why? i really need help.
Basically, from the thread , Paul asked you several times to do this:
But you constantly, ignored this. He is right, if you don't show us your exact query , how can you expect us to solve them. And yes, the error message clearly suggests there is an error in your sql syntax
Regards,
Vishal
Cezanne Khan wrote:
Paul Clapham wrote:Okay. You're a troll, then. No more answers from me.
why? i really need help.
Paul Clapham wrote:Okay. You're a troll, then. No more answers from me.
Paul Clapham wrote:It might be a good idea if you posted that exact SQL statement here. Somebody might see a problem with it.
(Notice that the "Code" button which you use to format code in the forum has an "SQL" option in the drop-down to the left of it, which makes SQL easier to read when it's posted here.)
chris webster wrote:As Paul says, print out the exact SQL statement that is actually generated and which actually causes the error.
Then copy this statement and execute it via your database's SQL query interface (i.e. not JFreeChart or Java) so you can see if the query works without multiple layers of Java between your SQL string and the database.
If it still doesn't work, then change it and test it via your database's SQL query interface until it's working correctly.
Then put the corrected SQL code back into your Java and test it again.
Watch out for special characters (e.g. single quotes, ampersands etc) inside the strings you use for Country and Series, because these may cause problems when your SQL reaches the database. If possible, test that the query executes successfully for every possible value of Country/Series.
Paul Clapham wrote:I say, if the package requires you to generate SQL in the form of a string, then do that.
Paul Clapham wrote:By the way: Generating SQL in that way is likely to lead to problems. First of all you have to make sure your quotes match, and you have the right kind of quotes in the right place. And then even if they do match, having more quotes in the string data which you concatenate together can make your quotes be unbalanced again. And also if your string data came from user input, it can be used for SQL injection attacks which can damage your database.
The usual advice here is to use a PreparedStatement, rather than building your SQL from strings like that. But I see that you are working with some kind of utility code which prefers those error-prone strings. So you should look at it to see if it will accept a PreparedStatement, perhaps in some other overloaded method. If so, you should switch to using that other method.
Paul Clapham wrote:Yes. The error message tells you that there's something wrong with your SQL. So look at your SQL.
And no, that bunch of Java code is not your SQL. It's a line of code which produces your SQL. So don't look at the Java code, look at the string which it produces. I already showed you how to look at that string.