在hibernate中,插入数据时一直报错:
2016-11-21 12:09:28,693 -- WARN -- org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:144) -- SQL Error: 1064, SQLState: 42000
2016-11-21 12:09:28,693 -- ERROR -- org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:146) -- 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 'usage) values (12, '12', '12', 10, 12.0, '???è??', '12')' at line 1
2016-11-21 12:09:28,708 -- ERROR -- com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error(CommonsLogger.java:38) -- Exception occurred during processing request: could not execute statement
org.hibernate.exception.SQLGrammarException: could not execute statement
刚开始一直以为是乱码的问题,但是不是,研究了之后,才发现是使用了SQL的关键字作为了字段,后来改了相对应的字段后,正常插入,其中使用的关键字为usage。
最主要的错误信息提示
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:144) -- SQL Error: 1064, SQLState: 42000
然后百度sql关键字查到链接,以备不时之需:http://www.360doc.com/content/12/0203/11/3688062_183844013.shtml
后期可能会整理一份待定