4 messages in com.mysql.lists.javaPrepared statemens do not work for so...
FromSent OnAttachments
Ralf Hauser11 Feb 2006 00:58 
Ralf Hauser19 Mar 2006 13:44 
Rhino19 Mar 2006 20:44 
Ralf Hauser29 May 2006 12:35 
Subject:Prepared statemens do not work for sort-order in ORDER BY clause
From:Ralf Hauser (ralf@gmx.ch)
Date:03/19/2006 01:44:33 PM
List:com.mysql.lists.java

Hi,

To prevent SQL injection attacks, we use PreparedStatements.

In an ORDER BY clause, we also set the sort order ASC or DESC via a ?

Unfortunately, if done so, this does not work.

When doing a log.debug, I see

ORDER BY 'sent_date' 'desc'

and the DESC is ignored by the DB and the results arrive as ASC.

When copying the log.debug query to the MySQL Query Browser, this behaviour can be reproduced.

As soon as I change to

ORDER BY 'sent_date' desc

all is fine.

Any hints how to do this in jdbc?

Regards

Ralf