【发布时间】:2019-11-15 18:09:37
【问题描述】:
我正在使用PostgreSQL 数据库创建Spring Boot 应用程序。我正在使用JDBCTemplate 来执行数据库操作。根据我的要求,我想要来自CONTRACT_VIEW_2 表的row 的count,其中LICENSE_PLATE = "xxxxxx" 和ZONE_CODE is IN ("x","y","z") 的值但我得到了PSQL 异常。
我尝试使用 MapSQLParameterSource,但仍然遇到问题。
@Override
public Integer getAllZoneForLp(String lp,List<String> zones) {
MapSqlParameterSource zoneIds = new MapSqlParameterSource();
zoneIds.addValue("zoneIds",zones);
String sql = "select " +
"count(*) " +
"from contract_view_2 " +
"where license_plate = ? and zone_code IN (?)";
return jdbcTemplate.queryForObject(sql,Integer.class,lp,zoneIds);
}
我希望结果中出现row count,但我得到的是PSQL Exception。我附上了我得到的异常的图像。
提前致谢。
【问题讨论】:
标签: java postgresql spring-boot jdbctemplate