sql injection violation, syntax

2022-11-22  本文已影响0人  饱饱抓住了灵感

类似于如下报错:

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语句错了, 可能原因有:

  1. sql语句写错了
  2. 表或字段占用了数据库关键字, 例如"说明"字段不能取名为desc, 因为desc是数据库关键字, 表示倒序
  3. 如果使用了jpa, 可能是高版本的spring不支持低版本的jpa写法, 例如jpa中in:ids, 低版本spring可以正常运行, 但高版本必须在in后面加空格
上一篇 下一篇

猜你喜欢

热点阅读