Example usage for org.springframework.jdbc UncategorizedSQLException getSQLException

List of usage examples for org.springframework.jdbc UncategorizedSQLException getSQLException

Introduction

In this page you can find the example usage for org.springframework.jdbc UncategorizedSQLException getSQLException.

Prototype

public SQLException getSQLException() 

Source Link

Document

Return the underlying SQLException.

Usage

From source file:om.edu.squ.squportal.portlet.dps.registration.dropw.db.DropWDBImpl.java

/**
 * /*  w  w w .j  a  va2 s  .c o  m*/
 * method name  : setDropWCourseWithdrawProc
 * @param dropWDTO
 * @return
 * DropWDBImpl
 * return type  : int
 * 
 * purpose      :
 *
 * Date          :   May 7, 2017 10:36:17 AM
 */
@Transactional
private Map setDropWCourseWithdrawProc(DropWDTO dropWDTO) throws NotSuccessFulDBUpdate {
    Map resultProc = null;

    simpleJdbcCallDpsDropW.withProcedureName(Constants.CONST_PROC_DROPW_WITHDRAW_COURSE);
    simpleJdbcCallDpsDropW.withoutProcedureColumnMetaDataAccess();
    simpleJdbcCallDpsDropW.useInParameterNames(Constants.CONST_PROC_COL_NAME_P_STDNO,
            Constants.CONST_PROC_COL_NAME_P_SECTCD, Constants.CONST_PROC_COL_NAME_P_SECTNO,
            Constants.CONST_PROC_COL_NAME_P_USER);
    simpleJdbcCallDpsDropW.declareParameters(
            new SqlParameter(Constants.CONST_PROC_COL_NAME_P_STDNO, Types.NUMERIC),
            new SqlParameter(Constants.CONST_PROC_COL_NAME_P_SECTCD, Types.NUMERIC),
            new SqlParameter(Constants.CONST_PROC_COL_NAME_P_SECTNO, Types.NUMERIC),
            new SqlParameter(Constants.CONST_PROC_COL_NAME_P_USER, Types.VARCHAR)

    );
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put(Constants.CONST_PROC_COL_NAME_P_STDNO, dropWDTO.getStudentNo());
    paramMap.put(Constants.CONST_PROC_COL_NAME_P_SECTCD, dropWDTO.getSectCode());
    paramMap.put(Constants.CONST_PROC_COL_NAME_P_SECTNO, dropWDTO.getSectionNo());
    paramMap.put(Constants.CONST_PROC_COL_NAME_P_USER, dropWDTO.getUserName());

    try {
        resultProc = simpleJdbcCallDpsDropW.execute(paramMap);
    } catch (BadSqlGrammarException badGrException) {
        logger.error("Might be a grammatical issue in stored procedure");
        throw new NotSuccessFulDBUpdate(badGrException.getMessage());
    } catch (UncategorizedSQLException exception) {
        logger.error("Course drop not successful for student no : {}, course no {} . Details : {} - {}",
                dropWDTO.getStudentNo(), dropWDTO.getCourseNo(), exception.getSQLException().getErrorCode(),
                exception.getSQLException().getMessage());
        throw new NotSuccessFulDBUpdate(exception.getMessage());

    }

    return resultProc;
}

From source file:org.jumpmind.symmetric.db.firebird.FirebirdSymmetricDialect.java

@Override
public void createRequiredDatabaseObjects() {
    String escape = this.parameterService.getTablePrefix() + "_" + "escape";
    if (!installed(SQL_FUNCTION_INSTALLED, escape)) {
        String sql = "declare external function $(functionName) cstring(32660)                                                                                                                                               "
                + "  returns cstring(32660) free_it entry_point 'sym_escape' module_name 'sym_udf'                                                                                          ";
        install(sql, escape);/*from ww w . j a  v  a  2 s.co m*/
    }

    String hex = this.parameterService.getTablePrefix() + "_" + "hex";
    if (!installed(SQL_FUNCTION_INSTALLED, hex)) {
        String sql = "declare external function $(functionName) blob                                                                                                                                                         "
                + "  returns cstring(32660) free_it entry_point 'sym_hex' module_name 'sym_udf'                                                                                             ";
        install(sql, hex);
    }

    try {
        platform.getSqlTemplate().queryForInt("select char_length(" + escape + "('')) from rdb$database");
    } catch (UncategorizedSQLException e) {
        if (e.getSQLException().getErrorCode() == -804) {
            log.error("Please install the sym_udf.so/dll to your {firebird_home}/UDF folder");
        }
        throw new RuntimeException("Function " + escape + " is not installed", e);
    }
}