Convenience method to retrieve an entire result
set into memory.

@param sql the SQL statement to be executed
@param maxrows the max. number of rows to retrieve
@param args arguments for the SQL statement, '%q' substitution
@return result set
436714
public TableResult get_table( String sql, int maxrows, String args[] ) throws jsqlite.Exception {
        TableResult ret = new TableResult(maxrows);
        if (!is3()) {
            try {
                exec(sql, ret, args);
            } catch (jsqlite.Exception e) {
                if (maxrows <= 0 || !ret.atmaxrows) {
                    throw e;
                }
            }
        } else {
            synchronized (this) {
                /* only one statement !!! */
                Vm vm = compile(sql, args);
                set_last_error(vm.error_code);
                if (ret.maxrows > 0) {
                    while( ret.nrows < ret.maxrows && vm.step(ret) ) {
                        set_last_error(vm.error_code);
                    }
                } else {
                    while( vm.step(ret) ) {
                        set_last_error(vm.error_code);
                    }
                }
                vm.finalize();
            }
        }
        return ret;
    }
993744
public ResultSet getResults() {
        final SQLListenerContextImpl context = startContext(connection(), queryMixin.getMetadata());
        String queryString = null;
        List<Object> constants = ImmutableList.of();

        try {
            listeners.preRender(context);
            SQLSerializer serializer = serialize(false);
            queryString = serializer.toString();
            logQuery(queryString, serializer.getConstants());
            context.addSQL(getSQL(serializer));
            listeners.rendered(context);

            listeners.notifyQuery(queryMixin.getMetadata());

            constants = serializer.getConstants();

            listeners.prePrepare(context);
            final PreparedStatement stmt = getPreparedStatement(queryString);
            setParameters(stmt, constants, serializer.getConstantPaths(), getMetadata().getParams());
            context.addPreparedStatement(stmt);
            listeners.prepared(context);

            listeners.preExecute(context);
            final ResultSet rs = stmt.executeQuery();
            listeners.executed(context);

            return new ResultSetAdapter(rs) {
                @Override
                public void close() throws SQLException {
                    try {
                        super.close();
                    } finally {
                        stmt.close();
                        reset();
                        endContext(context);
                    }
                }
            };
        } catch (SQLException e) {
            onException(context, e);
            reset();
            endContext(context);
            throw configuration.translate(queryString, constants, e);
        }
    }
511559
public List< T> getAllBySql(String fullSql, Integer offset, Integer limit) {
		return getAllBySql(fullSql, null, null, offset, limit);
	}
1132475
private List<Row> getRows(String sql) throws SQLException
   {
      allocateConnection();

      try
      {
         List<Row> result = new LinkedList<Row>();

         m_ps = m_connection.prepareStatement(sql);
         m_rs = m_ps.executeQuery();
         populateMetaData();
         while (m_rs.next())
         {
            result.add(new MpdResultSetRow(m_rs, m_meta));
         }

         return (result);
      }

      finally
      {
         releaseConnection();
      }
   }
731765
public <T> List<List<T>> queryTypedResults(String sql, String[] args) {
		return db.queryTypedResults(sql, args);
	}
82026
@Override
    public Map<String,Object> getRowData()
    {
        if (_resultSet == null)
        {
            return null;
        }
        else if (!isRowAvailable())
        {
            throw new IllegalArgumentException(
                "the requested row is not available in the ResultSet - you have scrolled beyond the end.");
        }

        try
        {
            return new WrapResultSetMap(String.CASE_INSENSITIVE_ORDER);
        }
        catch (SQLException e)
        {
            throw new FacesException(e);
        }
    }
354555
public RowResultSet<R> resultSet(int maxRows) {
        if (maxRows <= 0) {
            return new RowResultSet<R>(getRows());
        } // end of if

        return new RowResultSet<R>(getRows().subList(0, maxRows));
    }
433189
public function getRow($sql, array $args = [])
    {
        $query = $this->query($sql, $args);
        if (!$query) {
            return [];
        }
        
        $rs = $query->fetch(\PDO::FETCH_ASSOC);
        return $rs;
    }
1251055
public static Integer max(Connection connection, String table,
			String column, String where, String[] args) {

		Integer max = null;
		if (count(connection, table, where, args) > 0) {
			StringBuilder maxQuery = new StringBuilder();
			maxQuery.append("select max(")
					.append(CoreSQLUtils.quoteWrap(column)).append(") from ")
					.append(CoreSQLUtils.quoteWrap(table));
			if (where != null) {
				maxQuery.append(" where ").append(where);
			}
			String sql = maxQuery.toString();

			max = querySingleInteger(connection, sql, args, false);
		}

		return max;
	}
1230361
public ResultSet executeQuery(String sql) throws SQLException {
    if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) {
      return results.getResultSet();
    }
    return SelectResultSet.createEmptyResultSet();
  }
13845
public <T> List<T> querySingleRowTypedResults(String sql, String[] args) {
		@SuppressWarnings("unchecked")
		List<T> result = (List<T>) querySingleRowResults(sql, args);
		return result;
	}
775936
public Page<T> page(String sql, Object[] params, PageRow pageRow) {
        this.beforeCheck();
        Connection conn = getConn();
        try {
            String countSql = useSQL ? "SELECT COUNT(*) FROM (" + sql + ") tmp" : buildCountSQL(sql);

            long count = conn.createQuery(countSql)
                    .withParams(params)
                    .executeAndFetchFirst(Long.class);

            Page<T> pageBean = new Page<>(count, pageRow.getPageNum(), pageRow.getPageSize());

            ifThen(count > 0, () -> {
                String pageSQL = this.buildPageSQL(sql, pageRow);
                List<T> list = conn.createQuery(pageSQL)
                        .withParams(params)
                        .setAutoDeriveColumnNames(true)
                        .throwOnMappingFailure(false)
                        .executeAndFetch(modelClass);

                this.setJoin(list);
                pageBean.setRows(list);
            });

            return pageBean;
        } finally {
            this.closeConn(conn);
            this.clean(null);
        }
    }
249851
static ResultSet executeStatement(SQL sql) throws SQLException {
    try (SqlSession session = sqlSessionFactory.openSession(true)) {
      try (Connection conn = session.getConnection()) {
        try (Statement stmt = conn.createStatement()) {
          return stmt.executeQuery(sql.toString());
        }
      }
    }
  }
1001673
public List<Object> querySingleRowResults(String sql, String[] args,
			GeoPackageDataType[] dataTypes) {
		List<List<Object>> results = queryResults(sql, args, dataTypes, 1);
		List<Object> singleRow = null;
		if (!results.isEmpty()) {
			singleRow = results.get(0);
		}
		return singleRow;
	}
1368057
public static void updateBatch(String sql, Object[][] arg) {
        Connection connection = JDBCUtils.getConnection();
        PreparedStatement ps = null;
        try {
            ps = connection.prepareStatement(sql);
            for (int i = 0; i < arg.length; i++) {
                for (int j = 0; j < arg[i].length; j++) {
                    ps.setObject(j + 1, arg[i][j]);
                }
                ps.addBatch();
            }
            ps.executeBatch();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        JDBCUtils.release(ps, connection);
    }
879758
@Override
    Result getResult(Session session, int maxrows) {

        Result r;

        r = getSingleResult(session, maxrows);

        // fredt - now there is no need for the sort and group columns
//        r.setColumnCount(indexLimitVisible);
        r.getNavigator().reset();

        return r;
    }
1374350
function maxRecordNumber (args) {
    // get sql
    var select = sql.maxRecordNumber(this, args)
    // do query
    return this.mysql().query(select.sql, select.params)
    // get n value from response
    .then(res => {
        return res[0][0].n
    })
}