code: public static SQLException get(final String message, String sqlState, int errorCode,
        final Throwable exception, boolean timeout) {
      final SqlStates state = SqlStates.fromString(sqlState);
      switch (state) {
        case DATA_EXCEPTION:
          return new SQLDataException(message, sqlState, errorCode, exception);
        case FEATURE_NOT_SUPPORTED:
          return new SQLFeatureNotSupportedException(message, sqlState, errorCode, exception);
        case CONSTRAINT_VIOLATION:
          return new SQLIntegrityConstraintViolationException(message, sqlState, errorCode,
              exception);
        case INVALID_AUTHORIZATION:
          return new SQLInvalidAuthorizationSpecException(message, sqlState, errorCode, exception);
        case CONNECTION_EXCEPTION:
          return new SQLNonTransientConnectionException(message, sqlState, errorCode, exception);
        case SYNTAX_ERROR_ACCESS_RULE:
          return new SQLSyntaxErrorException(message, sqlState, errorCode, exception);
        case TRANSACTION_ROLLBACK:
          return new SQLTransactionRollbackException(message, sqlState, errorCode, exception);
        case WARNING:
          return new SQLWarning(message, sqlState, errorCode, exception);
        case INTERRUPTED_EXCEPTION:
          if (timeout && "70100".equals(sqlState)) {
            return new SQLTimeoutException(message, sqlState, errorCode, exception);
          }
          if (exception instanceof SQLNonTransientConnectionException) {
            return new SQLNonTransientConnectionException(message, sqlState, errorCode, exception);
          }
          return new SQLTransientException(message, sqlState, errorCode, exception);
        case TIMEOUT_EXCEPTION:
          return new SQLTimeoutException(message, sqlState, errorCode, exception);
        case UNDEFINED_SQLSTATE:
          if (exception instanceof SQLNonTransientConnectionException) {
            return new SQLNonTransientConnectionException(message, sqlState, errorCode, exception);
          }
          return new SQLException(message, sqlState, errorCode, exception);
        default:
          // DISTRIBUTED_TRANSACTION_ERROR,
          return new SQLException(message, sqlState, errorCode, exception);
      }
    }
docs: Helper to decorate exception with associate subclass of {@link SQLException} exception.
  
  @param message   exception message
  @param sqlState  sqlstate
  @param errorCode errorCode
  @param exception cause
  @param timeout   was timeout on query
  @return SQLException exception