birdy
birdy

Reputation: 9646

RowMapper is abstract cannot be instantiated

I'm trying to implement the solution mentioned on SO here However, i'm getting an error "Rowmapper is abstract cannot be instantiated" and "illegal start of expression". Below is exactly what I ha

List<String> strLst  = jdbcTemplate.query(query,
                    new RowMapper {
                        public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                            return rs.getString(1);
                        }
                    });

What if I have multiple ? in my query.

for example:

select * from table where a = ? and b = ?

how can I pass the parameters (?) into this query in the code above?

Upvotes: 2

Views: 2335

Answers (1)

Ray Toal
Ray Toal

Reputation: 88478

The code you are implementing makes use of an anonymous subclass of RowMapper. The correct syntax is:

new RowMapper() { ... }

You just inadvertently left out the ().

Upvotes: 4

Related Questions