1

以下のようなクエリを実行しようとしています

select col1 from table1 where col2 = ? and col3 = ?

JdbcTemplate を使用したい

私はこのように書くことができますか?

String query = new String("select col1 from table1 where col2 = ? and col3 = ?");
Object[] parameters = new Object[] {new String(col2), new String(col3)};

Object module = jdbcTemplate.queryForObject(query, parameters,"");


**Object module = jdbcTemplate.queryForObject(query, parameters,String.class);** is this right?
4

1 に答える 1

1

JdbcTemplateそのメソッドのオーバーロードされたバージョンがいくつかあります。どちらに電話するつもりですか?

RowMapper興味のあるオブジェクト タイプの実装を追加することができます。それをお勧めします。

public class YourRowMapper implements RowMapper<YourClass> {
    YourClass mapRow(ResultSet rs, int rowNum) throws SQLException {
        return new YourClass();  // map the ResultSet row here.
    }
}
于 2012-05-02T11:43:29.660 に答える