Spring3.2.2之后不赞成使用queryForInt

时间:2022-05-14 12:17:10

原来:

    public int getMatchCount(String username,String password){
        String sql="select count(*) from user_db where username=? and password=?";
        return jdbcTemplate.queryForInt(sql,new Object[]{username,password});
    }

现在:

    public int getMatchCount(String username,String password){
        String sql="select count(*) from user_db where username=? and password=?";
       return jdbcTemplate.queryForObject(sql,new Object[]{username,password},Integer.class);
    }

全部用queryForObject了(包括queryForLong)