private MjdbcSQLException translateSQLStatePrefix ( String reason , String SQLState , int vendorCode , SQLException cause ) { MjdbcSQLException result = null ; String sqlState = getSqlState ( cause ) ; String sqlStatePrefix = null ; if ( sqlState != null && sqlState . length ( ) >= 2 ) { sqlStatePrefix = sqlState . substring ( 0 , 2 ) ; if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_BAD_SQL_GRAMMAR . contains ( sqlStatePrefix ) == true ) { result = new BadSqlGrammarException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_DATA_INTEGRITY_VIOLATION . contains ( sqlStatePrefix ) == true ) { result = new DataIntegrityViolationException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_DATA_ACCESS_RESOURCE_FAILURE . contains ( sqlStatePrefix ) == true ) { result = new DataAccessResourceFailureException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_TRANSIENT_DATA_ACCESS_RESOURCE_EXCEPTION . contains ( sqlStatePrefix ) == true ) { result = new TransientDataAccessResourceException ( reason , SQLState , vendorCode ) ; } else if ( SpringExceptionHandlerConstants . SQL_STATE_PREFIX_CONCURRENCY_FAILURE . contains ( sqlStatePrefix ) == true ) { result = new ConcurrencyFailureException ( reason , SQLState , vendorCode ) ; } } return result ; }
Checks SQL state and tries to convert it into Spring SQL Exception . This implementation is vendor free .