Search code examples
javamysqlsqlhibernatemysql-error-1064

Hibernate and MYSQL: You have an error in your SQL syntax?


I have the following query in my java code:

String queryString = "select \r\n" +
        "cms.status_id as 'statusId',\r\n" +
        "cms.status_label as 'statusLabel',\r\n" +
        "csl.status as 'status',\r\n" +
        "from "+client+".my_status cms \r\n" +
        "join "+client+".status_list csl on csl.status = cms.status_id\r\n";

When I run the code I get the following error:

SQL Error: 1064, SQLState: 42000
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

What could be causing this? I cannot seen an issue with my query and manually I am able to get it working.


Solution

  • You have an extra comma in this line:

     "csl.status as 'status',\r\n" +