JdbcTemplate queryForInt/Long is deprecated in Spring 3.2.2. What should it be replaced by?

后端 未结 6 1449
慢半拍i
慢半拍i 2021-01-30 19:36

The queryforInt/queryforLong methods in JdbcTemplate are deprecated in Spring 3.2. I can\'t find out why or what is considered the best practice to replace existing code using t

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 19:56

    public int getCircleCount() {
        Object param = "1";
        String sql = "select count(*) from circle where id = ? ";
        jdbcTemplate.setDataSource(getDataSource());
        int result = getJdbcTemplate().queryForObject(sql, new Object[] { param }, Integer.class);
        return result;
    }
    

提交回复
热议问题