How to only return String objects from JdbcTemplate queryForList?

前端 未结 1 1257
醉话见心
醉话见心 2021-01-26 06:37

By default, queryForList() returns each for as a Map. The object can be plain String, java.sql.Timestamp

相关标签:
1条回答
  • 2021-01-26 06:48

    Maybe there is a better way, but the following works:

    jdbcTemplate.query(sql, params, new ColumnMapRowMapper() {
        @Override
        protected Object getColumnValue(ResultSet rs, int index) {
           return rs.getString(index);
        }
    }
    
    0 讨论(0)
提交回复
热议问题