use of org.springframework.jdbc.BadSqlGrammarException in project dhis2-core by dhis2.
the class JdbcEnrollmentAnalyticsManager method getEnrollmentCount.
@Override
public long getEnrollmentCount(EventQueryParams params) {
String sql = "select count(pi) ";
sql += getFromClause(params);
sql += getWhereClause(params);
long count = 0;
try {
log.debug("Analytics enrollment count SQL: " + sql);
if (params.analyzeOnly()) {
executionPlanStore.addExecutionPlan(params.getExplainOrderId(), sql);
} else {
count = jdbcTemplate.queryForObject(sql, Long.class);
}
} catch (BadSqlGrammarException ex) {
log.info(AnalyticsUtils.ERR_MSG_TABLE_NOT_EXISTING, ex);
} catch (DataAccessResourceFailureException ex) {
log.warn(ErrorCode.E7131.getMessage(), ex);
throw new QueryRuntimeException(ErrorCode.E7131, ex);
}
return count;
}
Aggregations