美文网首页
sql injection violation, syntax

sql injection violation, syntax

作者: 饱饱想要的灵感 | 来源:发表于2022-11-22 16:35 被阅读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后面加空格

相关文章

网友评论

      本文标题:sql injection violation, syntax

      本文链接:https://www.haomeiwen.com/subject/hgwnxdtx.html