Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prepared Statement syntax error - really, where?

843854Apr 15 2004 — edited Apr 16 2004
Can anybody spot why this code generates one of these errors?
  
int topQuarter = 3;
prepStmt = connection.prepareStatement("SELECT number, name, total, class FROM competitor WHERE class = 'A' ORDER BY total DESC LIMIT ?");
prepStmt.setString(1, Integer.toString(topQuarter));
rs = prepStmt.executeQuery();
java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax near ''3'' at line 1"

Note: The quotes before and after the 3 in the error are single quotes but after the 1 is a double quote.

They SQL query executes fine when I enter it directly at the mysql> command line.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2004
Added on Apr 15 2004
11 comments
976 views