Remember to add {@code limit} condition if big result will be returned by the query.

@param sql
@param parameters A Object Array/List, and Map/Entity with getter/setter methods for parameterized sql with named parameters
@return
350608
@SafeVarargs
    public final boolean exists(String sql, Object... parameters) {
        final Cursor cursor = rawQuery(sql, parameters);

        try {
            return cursor.moveToNext();
        } finally {
            cursor.close();
        }
    }
805111
public Object querySingleResult(String sql, String[] args, int column) {
		return db.querySingleResult(sql, args, column);
	}
1025885
public ResultSet query(String sql, String[] args) {
		return SQLUtils.query(connection, sql, args);
	}
766777
public void setParameter(final int parameterIndex, final ParameterHolder holder)
      throws SQLException {
    if (parameterIndex >= 1 && parameterIndex < prepareResult.getParamCount() + 1) {
      parameters[parameterIndex - 1] = holder;
    } else {
      String error = "Could not set parameter at position " + parameterIndex
          + " (values was " + holder.toString() + ")\n"
          + "Query - conn:" + protocol.getServerThreadId()
          + "(" + (protocol.isMasterConnection() ? "M" : "S") + ") ";

      if (options.maxQuerySizeToLog > 0) {
        error += " - \"";
        if (sqlQuery.length() < options.maxQuerySizeToLog) {
          error += sqlQuery;
        } else {
          error += sqlQuery.substring(0, options.maxQuerySizeToLog) + "...";
        }
        error += "\"";
      } else {
        error += " - \"" + sqlQuery + "\"";
      }

      logger.error(error);
      throw ExceptionMapper.getSqlException(error);
    }
  }
236473
public List<T> fetchList(int limit) throws SQLException, InstantiationException, IllegalAccessException {
        ArrayList<T> result = new ArrayList<T>();
        if (primitive) {
            for (int i = 0; i < limit; i++) {
                if (!finished) {
                    result.add(fetchSingleInternal());
                    next();
                } else {
                    break;
                }
            }
        } else {
            for (int i = 0; i < limit; i++) {
                if (!finished) {
                    result.add(fetchSingleInternal());
                    next();
                } else {
                    break;
                }
            }
        }

        return result;
    }
834241
public <T> List<T> querySingleColumnTypedResults(String sql, String[] args) {
		@SuppressWarnings("unchecked")
		List<T> result = (List<T>) querySingleColumnResults(sql, args);
		return result;
	}
1194251
def limitsSql(startIndex=0, maxResults=0):
    
    if startIndex and maxResults:
        return " LIMIT {}, {}".format(startIndex, maxResults)
    elif startIndex:
        raise Exception("startIndex was provided, but maxResults was not")
    elif maxResults:
        return " LIMIT {}".format(maxResults)
    else:
        return ""
1094228
private void get(final StringBuilder sql) {
        sql.append("SELECT * FROM ").append(getName()).append(" WHERE ").append(JdbcRepositories.getDefaultKeyName()).append(" = ?");
    }
796448
public static Map<String, Object> queryForMap(String sql, Object... args) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> list = queryForList(sql, args);
		if (list.size() > 0) {
			result = list.get(0);
		}
		return result;
	}
274011
public String queryString(String sql, Object... params) throws SQLException {
		return query(sql, new StringHandler(), params);
	}
362525
def get_query_with_new_limit(self, new_limit):
        """does not change the underlying query"""
        if not self._limit:
            return self.sql + ' LIMIT ' + str(new_limit)
        limit_pos = None
        tokens = self._parsed[0].tokens
        # Add all items to before_str until there is a limit
        for pos, item in enumerate(tokens):
            if item.ttype in Keyword and item.value.lower() == 'limit':
                limit_pos = pos
                break
        limit = tokens[limit_pos + 2]
        if limit.ttype == sqlparse.tokens.Literal.Number.Integer:
            tokens[limit_pos + 2].value = new_limit
        elif limit.is_group:
            tokens[limit_pos + 2].value = (
                '{}, {}'.format(next(limit.get_identifiers()), new_limit)
            )

        str_res = ''
        for i in tokens:
            str_res += str(i.value)
        return str_res
306223
public ParametricStatement set(String sql) throws IllegalArgumentException {
        if (_env != null) {
            try { sql = Macro.expand(sql, _env.call()); } catch (Exception x) { throw new IllegalArgumentException(x.getMessage(), x); }
        }
    if (_params != null) {
        int count = 0;
        int qmark = sql.indexOf('?');
        while (qmark > 0) {
            ++count;
            qmark = sql.indexOf('?', qmark+1);
        }
        if (_params.length == count) {
            _sql = sql;
        } else {
            throw new IllegalArgumentException("Wrong number of parameters in '" + sql +'\'');
        }
    } else {
        List<Param> params = new ArrayList<Param>();
        _sql = transformer.invoke(new StringBuilder(), params, sql).toString();
        _params = params.toArray(new Param[params.size()]);
    }
        return this;
    }
785469
public Statement getPreparedStatement(String sql,
			Object[] parameters, boolean returnValues) throws DatabaseException {
		Statement stmt = null;
		try {
			if(supportPreparedStatement()){
				if (appendReturningColumnClause() && returnValues) {
					stmt = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
				} else {
					stmt = connection.prepareStatement(sql);
				}
				if (parameters != null) {
					for (int i = 0; i < parameters.length; i++) {
						((PreparedStatement)stmt).setObject(i + 1,getEquivalentDBObject(parameters[i]));
					}
				}
			}else{//no substition of parameters
				stmt = connection.createStatement();
				return stmt;
			}
		} catch (SQLException e) {
			logSQL(stmt, sql, parameters, true);
			e.printStackTrace();
			throw new DataEntryException(e.getMessage());
		}
		return stmt;
	}
584145
public List<?> selectList(String statement, Object parameter){
    statement = dbSqlSessionFactory.mapStatement(statement);
    List<Object> resultList = sqlSession.selectList(statement, parameter);
    for (Object object : resultList) {
      fireEntityLoaded(object);
    }
    return resultList;
  }
892351
public @NotNull QueryBuilder append(@NotNull String sql, @NotNull Collection<?> args) {
        query.append(requireNonNull(sql));
        addArguments(args);
        return this;
    }
687080
public int execute(String sql, List<Object> params) {
        return this.execute(sql, params.toArray());
    }
1164249
public void setSqlParameterValues(List<Object> sqlParameterValues) {
        if (sqlParameterValues != null) {
            this.sqlParameterValues = new ArrayList<Object>(sqlParameterValues);
        } else {
            this.sqlParameterValues = null;
        }
    }