• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
replied
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic