Skip to content

Instantly share code, notes, and snippets.

@sapanparikh18
Created June 13, 2018 14:10
Show Gist options
  • Save sapanparikh18/c1272b8b9d3d2f500e9f9caa06320da2 to your computer and use it in GitHub Desktop.
Save sapanparikh18/c1272b8b9d3d2f500e9f9caa06320da2 to your computer and use it in GitHub Desktop.
public Reviewanswer getAnswer(int questionId) throws DataNotFoundException {
String sql = "select * from answers where questionid=:questionId";
Map<String, Object> params = new HashMap<>();
params.put("questionId",questionId);
Reviewanswer answer = new Reviewanswer();
try {
answer = namedParameterJdbcTemplate.queryForObject(sql,params,Reviewanswer.class);
}catch (DataAccessException ex){
if("data not found(or something on similar lines)".equals(ex.getMessage())){
throw new DataNotFoundException();
}
}
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment