I‘m using springs jdbctemplate and running a query like below:
SELECT COLNAME FROM TABLEA GROUP BY COLNAME
There are no named parameters being passed, however, column name, COLNAME
, will be passed by the user.
Questions
-
Is there a way to have placeholders, like
?
for column names? For exampleSELECT ? FROM TABLEA GROUP BY ?
-
If I want to simply run the above query and get a
List<String>
what is the best way?
Currently I‘m doing:
List <Map<String, Object>> data = getJdbcTemplate().queryForList(query);
for (Map m : data)
System.out.println(m.get("COLNAME"));