'Spring에서 SQL Eception 처리'에 해당되는 글 1건

  1. 2014.07.23 [펌] Spring에서 SQL Eception 처리
반응형

if (ex instanceof DataAccessException) {

       SQLException se = (SQLException) ((DataAccessException) ex).getRootCause();

       msg = se.getMessage();

       LOGGER.debug("****** DataAccessException : {} // {}", se.getErrorCode(), se.getMessage());

}


if (ex instanceof BadSqlGrammarException) {

       SQLException se = ((BadSqlGrammarException) ex).getSQLException();

       LOGGER.debug("**BadSqlGrammarException {} ", se.getErrorCode());

}

else if (ex instanceof InvalidResultSetAccessException) {

       SQLException se = ((InvalidResultSetAccessException) ex).getSQLException();

       LOGGER.debug("**InvalidResultSetAccessException {} ", se.getErrorCode());

}

else if (ex instanceof DuplicateKeyException) {

       LOGGER.debug("**DuplicateKeyException {} ", ex.getMessage());

}

else if (ex instanceof DataIntegrityViolationException) {

       LOGGER.debug("**DataIntegrityViolationException {} ", ex.getMessage());

}

else if (ex instanceof DataAccessResourceFailureException) {

       LOGGER.debug("**DataAccessResourceFailureException {} ", ex.getMessage());

}

else if (ex instanceof CannotAcquireLockException) {

       LOGGER.debug("**CannotAcquireLockException {} ", ex.getMessage());

}

else if (ex instanceof DeadlockLoserDataAccessException) {

       LOGGER.debug("**DeadlockLoserDataAccessException {} ", ex.getMessage());

}

else if (ex instanceof CannotSerializeTransactionException) {

       LOGGER.debug("**CannotSerializeTransactionException {} ", ex.getMessage());

}

org.springframework.jdbc.support.SQLErrorcodesSQLExceptionTranslator Class


Posted by 1010