return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
return new BadSqlGrammarException(task, (sql != null ? sql : ""), sqlEx);
return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
@Test public void testExceptionHandler() { Map<Class<? extends Exception>, HttpStatus> map = new HashMap<Class<? extends Exception>, HttpStatus>(); map.put(IllegalArgumentException.class, HttpStatus.BAD_REQUEST); map.put(UnsupportedOperationException.class, HttpStatus.BAD_REQUEST); map.put(BadSqlGrammarException.class, HttpStatus.BAD_REQUEST); map.put(DataIntegrityViolationException.class, HttpStatus.BAD_REQUEST); map.put(HttpMessageConversionException.class, HttpStatus.BAD_REQUEST); map.put(HttpMediaTypeException.class, HttpStatus.BAD_REQUEST); endpoints.setStatuses(map); endpoints.setMessageConverters(new HttpMessageConverter<?>[] { new ExceptionReportHttpMessageConverter() }); MockHttpServletRequest request = new MockHttpServletRequest(); validateView(endpoints.handleException(new ScimResourceNotFoundException(""), request), HttpStatus.NOT_FOUND); validateView(endpoints.handleException(new UnsupportedOperationException(""), request), HttpStatus.BAD_REQUEST); validateView(endpoints.handleException(new BadSqlGrammarException("", "", null), request), HttpStatus.BAD_REQUEST); validateView(endpoints.handleException(new IllegalArgumentException(""), request), HttpStatus.BAD_REQUEST); validateView(endpoints.handleException(new DataIntegrityViolationException(""), request), HttpStatus.BAD_REQUEST); }
doThrow(new BadSqlGrammarException(??, ??, ??)).when(accountMapper).createBadGrammarException();
@Override public void interpret(StatementRuntime runtime) { // 转换语句中的表达式 ExqlContextImpl context = exqlContextPool.get(); context.clear(); try { ExqlPattern pattern = ExqlPatternImpl.compile(runtime.getSQL()); Map<String, Object> constants = runtime.getMetaData().getDAOMetaData() .getConstants(); pattern.execute(context, runtime.getParameters(), constants); runtime.setArgs(context.getArgs()); runtime.setSQL(context.flushOut()); } catch (Exception e) { String daoInfo = runtime.getMetaData().toString(); throw new BadSqlGrammarException(daoInfo, runtime.getSQL(), new SQLSyntaxErrorException(daoInfo + " @SQL('" + runtime.getSQL() + "')", e)); } }
throw new BadSqlGrammarException("No column named '" + columnName + "' exists in result set", this.getSql(), null);
final Object attrNameObj = rowResult.get(keyColumn); if (attrNameObj == null && !rowResult.containsKey(keyColumn)) { throw new BadSqlGrammarException("No column named '" + keyColumn + "' exists in result set", this.getSql(), null); final Object attrValue = rowResult.get(valueColumn); if (attrValue == null && !rowResult.containsKey(valueColumn)) { throw new BadSqlGrammarException("No column named '" + valueColumn + "' exists in result set", this.getSql(), null);
userName = userNameValue.toString(); } else { throw new BadSqlGrammarException("No userName column named '" + userNameAttribute + "' exists in result set and no userName provided in query Map", this.getQueryTemplate(), null); throw new BadSqlGrammarException("No attribute key column named '" + keyColumn + "' exists in result set", this.getQueryTemplate(), null); final Object attrValue = queryResult.get(valueColumn); if (attrValue == null && !queryResult.containsKey(valueColumn)) { throw new BadSqlGrammarException("No attribute value column named '" + valueColumn + "' exists in result set", this.getQueryTemplate(), null);
userName = userNameValue.toString(); } else { throw new BadSqlGrammarException("No userName column named '" + userNameAttribute + "' exists in result set and no userName provided in query Map", this.getQueryTemplate(), null); throw new BadSqlGrammarException("No attribute key column named '" + keyColumn + "' exists in result set", this.getQueryTemplate(), null); final Object attrValue = queryResult.get(valueColumn); if (attrValue == null && !queryResult.containsKey(valueColumn)) { throw new BadSqlGrammarException("No attribute value column named '" + valueColumn + "' exists in result set", this.getQueryTemplate(), null);
userName = userNameValue.toString(); } else { throw new BadSqlGrammarException("No userName column named '" + userNameAttribute + "' exists in result set and no userName provided in query Map", this.getQueryTemplate(), null); throw new BadSqlGrammarException("No attribute key column named '" + keyColumn + "' exists in result set", this.getQueryTemplate(), null); final Object attrValue = queryResult.get(valueColumn); if (attrValue == null && !queryResult.containsKey(valueColumn)) { throw new BadSqlGrammarException("No attribute value column named '" + valueColumn + "' exists in result set", this.getQueryTemplate(), null);
@Override protected DataAccessException doTranslate(String task, String sql, SQLException ex) { String sqlState = getSqlState(ex); if (sqlState != null && sqlState.length() >= 2) { String classCode = sqlState.substring(0, 2); if (logger.isDebugEnabled()) { logger.debug("Extracted SQL state class '" + classCode + "' from value '" + sqlState + "'"); } if (BAD_SQL_GRAMMAR_CODES.contains(classCode)) { return new BadSqlGrammarException(task, sql, ex); } else if (DATA_INTEGRITY_VIOLATION_CODES.contains(classCode)) { return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex); } else if (DATA_ACCESS_RESOURCE_FAILURE_CODES.contains(classCode)) { return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex); } else if (TRANSIENT_DATA_ACCESS_RESOURCE_CODES.contains(classCode)) { return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex); } else if (CONCURRENCY_FAILURE_CODES.contains(classCode)) { return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex); } } return null; }
return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
return new BadSqlGrammarException("Hive query", "", new SQLException(cause, sqlState)); return new BadSqlGrammarException("Hive query", "", new SQLException(cause, sqlState)); return new BadSqlGrammarException("Hive query", "", new SQLException(cause, sqlState));
return new BadSqlGrammarException(task, sql, sqlEx);
return new BadSqlGrammarException(task, (sql != null ? sql : ""), sqlEx);
@Override public void interpret(StatementRuntime runtime) { // 转换语句中的表达式 ExqlPattern pattern = ExqlPatternImpl.compile(runtime.getSQL()); ExqlContextImpl context = new ExqlContextImpl(runtime.getSQL().length() + 32); try { pattern.execute(context, runtime.getParameters(), runtime.getMetaData() .getDAOMetaData().getConstants()); runtime.setArgs(context.getParams()); runtime.setSQL(context.flushOut()); } catch (Exception e) { String daoInfo = runtime.getMetaData().toString(); throw new BadSqlGrammarException(daoInfo, runtime.getSQL(), new SQLSyntaxErrorException(daoInfo + " @SQL('" + runtime.getSQL() + "')", e)); } }
@Override public void interpret(StatementRuntime runtime) { // 转换语句中的表达式 ExqlPattern pattern = ExqlPatternImpl.compile(runtime.getSQL()); ExqlContextImpl context = new ExqlContextImpl(runtime.getSQL().length() + 32); try { pattern.execute(context, runtime.getParameters(), runtime.getMetaData() .getDAOMetaData().getConstants()); runtime.setArgs(context.getParams()); runtime.setSQL(context.flushOut()); } catch (Exception e) { String daoInfo = runtime.getMetaData().toString(); throw new BadSqlGrammarException(daoInfo, runtime.getSQL(), new SQLSyntaxErrorException(daoInfo + " @SQL('" + runtime.getSQL() + "')", e)); } }
return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
return new BadSqlGrammarException(task, sql, ex);