aspose file tools*
The moose likes JDBC and the fly likes com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException" Watch "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException" New topic
Author

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
i would like to retrieve a field which is defined the datatype 'varchar(45)'

when i enter number to retrieve that field as below:

select * from ATable where field='123';

it causes sql syntax error
why?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Your query is wrongly formatted. Print the final query and execute the same on the MySQL query analyzer.
And this is not the right section to ask JDBC question.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Li Jenny
Ranch Hand

Joined: Apr 19, 2010
Posts: 57
replied
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Li Jenny wrote:when i enter number to retrieve that field as below:

select * from ATable where field='123';

it causes sql syntax error
why?

This SQL is syntactically correct. The problem is the SQL query which gets formatted when you assign the parameter in JDBC code. I repeat, check the resultant query from JDBC code. The problem is there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException