org.springframework.jdbc.BadSqlGrammarException: # # # Error querying database. Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; Check the manual, corresponds to your MySQL server version forThe right syntax to use near ' order WHERE id = 5 ' at line 1# # # The error may exist in file [I:\workspace\workspace_wxjc\creation-help\creation-help-server\target\classes\mybatis\mapper\order-mapper.xml]### The error may involve Com.wxjc.creation.dao.impl.OrderDAOImpl.getById-inline### the error occurred whilesetting parameters### sql:select* FROM order WHERE id =?# # # Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; check the Manual that corresponds to your MySQL server version forThe right syntax to use near ' order WHERE id = 5 ' at line 1; bad SQL Grammar []; nested exception is Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error In your SQL syntax; Check the manual, corresponds to your MySQL server version forThe right syntax to use near ' order WHERE id = 5 ' at line 1At Org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate ( Sqlerrorcodesqlexceptiontranslator.java:237) at Org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate ( Abstractfallbacksqlexceptiontranslator.java:72) at Org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible ( Mybatisexceptiontranslator.java:71) at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (Sqlsessiontemplate.java:365) at Com.sun.proxy. $Proxy 23.selectOne (Unknown Source) at Org.mybatis.spring.SqlSessionTemplate.selectOne (sqlses Siontemplate.java:160) at Com.nskbearing.core.dao.BaseDAOImpl.getById (Basedaoimpl.java:125)
The above is an error prompt, prompt:
SELECT * FROM order WHERE id =?;
Hint org.springframework.jdbc.BadSqlGrammarException:
Put to MySQL client execution, also error
SELECT * from Order WHERE = 1 ; /* SQL Error (1064): You have a error in your SQL syntax; check the manual, corresponds to your MySQL server version for the right syntax to use near ' order*/* affected rows:0 records found: 0 Warning: 0< c18/>* *
Final Solution:
SELECT * from ' order ' WHERE id = 1;
It's settled.
Used in MyBatis:
<sql id= "T_order" >' order '</sql>
Solve!!!
MySQL table name is an order crud error