类似于如下报错:
org.springframework.orm.jpa.JpaSystemException: could not prepare statement; nested exception is org.hibernate.exception.GenericJDBCException: could not prepare statement
...
Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement
...
Caused by: java.sql.SQLException: sql injection violation, syntax error: ERROR. token : DESC, pos : 28 : insert into person_log (desc, person_id) values (?, ?)
...
Caused by: com.alibaba.druid.sql.parser.ParserException: ERROR. token : DESC, pos : 28
...
一般是sql语句错了, 可能原因有:
- sql语句写错了
- 表或字段占用了数据库关键字, 例如"说明"字段不能取名为
desc
, 因为desc
是数据库关键字, 表示倒序 - 如果使用了jpa, 可能是高版本的spring不支持低版本的jpa写法, 例如jpa中
in:ids
, 低版本spring可以正常运行, 但高版本必须在in
后面加空格
网友评论