Two Laptop Bag*
The moose likes JDBC and the fly likes MySQL error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL error" Watch "MySQL error" New topic
Author

MySQL error

Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
Hi all,

The query is "SELECT * FROM tblPages t WHERE t.SiteID=1000 AND t.DisplayModule = 'on' and t.Deleted = 'N' order by t.navorder"

When i execute the above query using JDBC i get the following Exception:

java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY t.navorder' at line 1"


but when i execute the same query at the command prompt it works without any problem.

I am using MySQL 4.1 database

Please help,
Seshu


Sree Jag<br />SCJP 1.4
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
use PreparedStatement to do that. like

String qry = "SELECT * FROM tblPages WHERE SiteID=? AND DisplayModule = ? and Deleted = ? order by navorder"

Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
I tried that,
the same error comes up

what could be the problem?

seshu
 
 
subject: MySQL error
 
Similar Threads
Syntax error
apostrophe ( ' ) issue in SQL of Hibernate.
Selecting the last record in the table using Hibernate
what wrong with 1=1 ?
someone please help me out with this thing