JdbcTemplate has another query() method which takes arguments of the prepared statement as parameter:
jdbcTemplateObject.query(SQL, new Object[] {branchName}, new RowMapper() {...});
Note that:
SQL
should be namedsql
- You should use
List
and notArrayList
. Nothing in the javadoc guarantees that an ArrayList is returned. And you shouldn't care about the concrete type of list returned. - You should use a
RowMapper<String>
and not a rawRowMapper
.