Search in sources :

Example 16 with BadSqlGrammarException

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;
}
Also used : BadSqlGrammarException(org.springframework.jdbc.BadSqlGrammarException) DataAccessResourceFailureException(org.springframework.dao.DataAccessResourceFailureException) QueryRuntimeException(org.hisp.dhis.common.QueryRuntimeException) TextUtils.getQuotedCommaDelimitedString(org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString)

Aggregations

BadSqlGrammarException (org.springframework.jdbc.BadSqlGrammarException)16 SQLException (java.sql.SQLException)7 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)6 QueryRuntimeException (org.hisp.dhis.common.QueryRuntimeException)4 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)4 Test (org.junit.jupiter.api.Test)4 DataAccessException (org.springframework.dao.DataAccessException)4 TextUtils.getQuotedCommaDelimitedString (org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString)3 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)3 TransientDataAccessResourceException (org.springframework.dao.TransientDataAccessResourceException)3 BatchUpdateException (java.sql.BatchUpdateException)2 DateUtils.getMediumDateString (org.hisp.dhis.util.DateUtils.getMediumDateString)2 DeadlockLoserDataAccessException (org.springframework.dao.DeadlockLoserDataAccessException)2 PermissionDeniedDataAccessException (org.springframework.dao.PermissionDeniedDataAccessException)2 InvalidResultSetAccessException (org.springframework.jdbc.InvalidResultSetAccessException)2 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)2 Async (org.springframework.scheduling.annotation.Async)2 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1