I’m trying to run a query like the one below
select col1 from table1 where col2 = ? and col3 = ?
I would like to use JdbcTemplate
can I write like this?
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?
JdbcTemplatehas several overloaded versions of that method. Which one do you intend to call?You can add in a
RowMapperimplementation for the object type you’re interested in. That’s what I’d recommend.