I am using the mysql-connector-java-3.1.7-bin.jar for my JDBC connection to my database and i am having a strange problem when executing a query. It does not seem to pay attention to my 'order by' clauses. I will do a print-out of the prepare statement before i execute it and i will get one result, then i'll paste it into the SQL window of MySQL and get another...
I can actually stick an invalid field name in after order by and it will still execute the query without throwing an exeption, but it will not do that in the SQL window, it will show up as a problem. Anyone seen this before, any suggestions i can try?
Greg B [ March 14, 2005: Message edited by: Bear Bibeault ]
select * from minwage where effective like ? and province like ? order by ? ASC
so after the prepare statement loads the parameters it will look exactly like i would want it to
select * from minwage where effevtive like '%77%' and province like '%N%' order by 'wage' ASC
problem is it will not execute the order by, so even if i submit a bad value for the order by, something that does not even exist, i will still get a resultset rather than the error that i should, it appears the order by is being ignored???
Here is a system out just before parameter loading, and then before execution, i plyed with the method a bit so it's different than above.
com.mysql.jdbc.ServerPreparedStatement - select * from minwage where province like null order by null desc
com.mysql.jdbc.ServerPreparedStatement - select * from minwage where province like '%Fed%' order by 'wage' desc
the above line pasted into SQL window retrieves the desired results, however executing the pstmt, does not bring back the desired results? Very frustrating and not much info on similar issues??? [ March 15, 2005: Message edited by: Greg Belyea ]
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
posted 15 years ago
Yes that does work, it does complicate what the knowledge the user must have on the client side but it may not be too much of an issue. Thanks for the help, i still find it a bit odd the in the SQL window, the results come back no prob with 'wage', but it won't for the application, but i am not gonna spend much time on it...
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me: