mysql中表名是order的CRUD的錯誤


org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 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 while setting parameters
### SQL: SELECT * FROM  order  WHERE id = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 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 have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  WHERE id = 5' at line 1
    at 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.$Proxy23.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
    at com.nskbearing.core.dao.BaseDAOImpl.getById(BaseDAOImpl.java:125)

以上是錯誤提示,提示:

SELECT * FROM  order  WHERE id = ?;

提示org.springframework.jdbc.BadSqlGrammarException: 

放到mysql的客戶端執行,也報錯

 

SELECT * FROM  order  WHERE id = 1;
/* SQL錯誤(1064):You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  WHERE id = 1' at line 1 */
/* Affected rows: 0  已找到記錄: 0  警告: 0  持續時間 0 of 1 query: 0.000 sec. */

最終解決:

SELECT * FROM  `order`  WHERE id = 1;

這樣解決了。
在mybatis中使用:
<sql id="t_order">`order`</sql>

解決!!!
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM