今天遇到一个问题就是insert的时候语法没问题 插入日志也没问题 但是就是插不进去(忙了一上午啊 我的时间啊 可恶)
报错如图:
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3180131e] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1409112532 wrapping com.mysql.cj.jdbc.ConnectionImpl@43c3354] will not be managed by Spring
==> Preparing: INSERT INTO order ( pk_id, order_price, product_id ) VALUES ( ?, ?, ? )
==> Parameters: 1(String), 50(Integer), 1501002853813071874(String)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3180131e]
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: 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 ( pk_id,
order_price,
product_id ) VALUES ( '1',
50,
'15010028538130718' at line 1
### The error may exist in com/zhang/mapper/OrderMapper.java (best guess)
### The error may involve com.zhang.mapper.OrderMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO order ( pk_id, order_price, product_id ) VALUES ( ?, ?, ? )
### Cause: java.sql.SQLSyntaxErrorException: 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 ( pk_id,
order_price,
product_id ) VALUES ( '1',
50,
'15010028538130718' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 ( pk_id,
order_price,
product_id ) VALUES ( '1',
50,
'15010028538130718' at line 1
然后关注点放在
Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to
左想想 右想想
我把表名改了 order->pro_order他就没问题了 可恶啊(order为mysql的关键字 拼接sql语句会出现问题)