今天做一个订单表,报了下面的异常,百思不得其解,找了半天问题还是没有找到,最后找度娘,百度了一下,才明白原来order是mysql的保留字,不能作为表名,修改以后,这个问题解决了,但又爆出另一个异常,又弄了半天,最后把sql 语句还有实体类都重写了一下,最后就解决了,我认为可能是我的sql语句中的字段名和数据库的字段名有误差,造成了这个错误!
第一个异常
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(order_phone,order_number,order_alipayzh,order_money)values('15210135636','' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInst