1. 程式人生 > >com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;



SQL: insert into order      ( user_id,                       order_id,                       product_id,                       consumer_name,                       dev_number,                       rant_month,                       total_fee,                       create_time,                              remark )       values ( ?,                       ?,                       ?,                       ?,                       ?,                       ?,                       ?,                       ?,                              ? )
### 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
     ( user_id,
      
      
        order_id,
      
      
        prod' 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
     ( user_id,
      
      
        order_id,
      
      
        prod' at line 1] with root 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
     ( user_id,
      
      
        order_id,
      
      
        prod' at line 1

運用mybatis逆向工程生成專案 新增一條資料報錯第一行程式碼錯誤 一開始以為是應用層的問題 Dao以上的程式碼哪裡錯了 後來去資料庫排查才發現是表名和預留字衝突問題 表名為order了 order為保留欄位 所以報錯了 把表名改個名字就好了

挖坑