This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes MySQL Syntax Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL Syntax Exception" Watch "MySQL Syntax Exception" New topic
Author

MySQL Syntax Exception

Ketul Parikh
Greenhorn

Joined: Jul 17, 2009
Posts: 14
I have following SQL :

UPDATE TABLE_NAME SET FIELD_NAME = FIELD_NAME -1 WHERE ANOTHER_FIELD_NAME= 311;

I get success when i run this query directly from query browser.

However, through my java program, when i create a preparedStatement and call its execute() method it throws following MySQL Syntax Exception.

Other Details :

MySQL Connector Jar - mysql-connector-java-5.1.15-bin.jar
MySQL Version : 5.1
OS : CentOs 5.1

KETUL
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Ketul Parikh wrote:I have following SQL :

UPDATE TABLE_NAME SET FIELD_NAME = FIELD_NAME -1 WHERE ANOTHER_FIELD_NAME= 311;

I get success when i run this query directly from query browser.

However, through my java program, when i create a preparedStatement and call its execute() method it throws following MySQL Syntax Exception.

Other Details :

MySQL Connector Jar - mysql-connector-java-5.1.15-bin.jar
MySQL Version : 5.1
OS : CentOs 5.1


can you post the code where you create the preparedStatement?

and post the Syntax Exception? I think you forgot to paste it in there.
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

Tim McGuire wrote:

can you post the code where you create the preparedStatement?

and post the Syntax Exception? I think you forgot to paste it in there.


Regards, Atul.
I came to this world on a Learner's License
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MySQL Syntax Exception