org.postgresql.util.PSQLException: ERROR: syntax error at or near “$1“的解决办法
org.postgresql.util.PSQLException: ERROR: syntax error at or near “$1“的解决办法
·
mapper.xml中定义的postgre SQL语句运行时报错:org.postgresql.util.PSQLException: ERROR: syntax error at or near “$1“
SELECT * from m_user where resigndt >= now()- INTERVAL #{flag} and resigndt <= now();
是数据转换异常(例如:Integer和String间转换异常) ,
解决方法1.将#改成$,$可转换成数值类型,但是使用$无法防止Sql注入
解决办法2. 将 INTERVAL #{flag} 替换成 #{flag}::INTERVAL
SELECT * from m_user where resigndt >= now()- #{flag}::INTERVAL and resigndt <= now()
更多推荐
已为社区贡献1条内容
所有评论(0)