-1

昨日、mapRow から値を返そうとしたときに問題が発生しました

strings.addAll(getJdbcTemplate().query(query, new RowMapper<String>() {
    @Override
    public String mapRow(ResultSet resultSet, int i) throws SQLException {
        if(?????????)
            return "--";
        else
            return resultSet.getString("S_PEOPLE_QUANTITY");
        }
    }
));

結果セットにゼロ行が含まれている場合、たとえば「--」を返すにはどうすればよいですか? 「?????????」の代わりに2使用するもの ?

4

2 に答える 2

0

「?????????」の代わりにこの if 条件を使用します。

if (!resultSet.next()){
// if this condition is true Resultset is empty
}

Javaのドキュメントから

When a call to the next method returns false, the cursor is positioned after the last row.
于 2013-04-19T10:46:35.653 に答える