当前位置:   article > 正文

使用JdbcTemplate操作postgresql数据库进行模糊查询遇到的问题及解决_could not determine data type of parameter $2

could not determine data type of parameter $2

最近公司项目涉及到了自动建表这一块,查询的时候也就只能动态生成sql使用JdbcTemplate进行查询,在模糊查询时使用.append(" like '%?%' ") 是识别不到占位符的,.append(" like '%'?'%' ")也是报错,使用.append(" like CONCAT('%',?,'%') ")则识别不到参数类型,

ERROR: could not determine data type of parameter $2

通过指定类型解决。

最终的解决方案是.append(" like CONCAT('%',?::varchar,'%') ")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/972489
推荐阅读
相关标签
  

闽ICP备14008679号