Helper method to create an alias object from a result set.<p>

@param resultset the result set
@return the alias object created from the result set

@throws SQLException if something goes wrong
498207
protected CmsAlias internalReadAlias(ResultSet resultset) throws SQLException {

        String siteRoot = resultset.getString(1);
        String path = resultset.getString(2);
        int mode = resultset.getInt(3);
        String structId = resultset.getString(4);
        return new CmsAlias(new CmsUUID(structId), siteRoot, path, CmsAliasMode.fromInt(mode));
    }
682549
public QueryBuilder fromAllNodesAs( String alias ) {
        AllNodes allNodes = new AllNodes(selector(alias));
        SelectorName oldName = this.source instanceof Selector ? ((Selector)source).name() : null;
        // Go through the columns and change the selector name to use the new alias ...
        for (int i = 0; i != columns.size(); ++i) {
            Column old = columns.get(i);
            if (old.selectorName().equals(oldName)) {
                columns.set(i, new Column(allNodes.aliasOrName(), old.getPropertyName(), old.getColumnName()));
            }
        }
        this.source = allNodes;
        return this;
    }
20499
private ResultSet integrityCheck(ResultSet resultSet) {
		try {
			if (resultSet.next()) {
				String value = resultSet.getString(1);
				if (value.equals("ok")) {
					resultSet.close();
					resultSet = null;
				}
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Integrity check failed on database: " + getName(), e);
		}
		return resultSet;
	}
1106856
public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception {
        ConnectionService connectionService = new ConnectionService();
        try (final Connection connection = connectionService.setUpConnection(sqlInputs)) {
            connection.setReadOnly(true);

            Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency());

            statement.setQueryTimeout(sqlInputs.getTimeout());
            final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand());

            final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter());
            if (resultSet != null) {
                resultSet.close();
            }
            return resultSetToDelimitedColsAndRows;
        }
    }
609880
public <T> T executeQuery(@NotNull ResultSetProcessor<T> processor, @NotNull @SQL String sql, Object... args) {
        return executeQuery(processor, SqlQuery.query(sql, args));
    }
143592
protected final void useResultSet( ResultSet pResultSet ) throws SQLException
  {
    boolean lFirst = true;

    if( !pResultSet.next() )
    {
      handleEmptyResultSet();
    }
    else
    {
      while( lFirst || pResultSet.next() )
      {
        lFirst = false;

        useResultSetRow( pResultSet );
      }
    }
  }
933817
protected CmsUrlNameMappingEntry internalCreateUrlNameMappingEntry(ResultSet resultSet) throws SQLException {

        String name = resultSet.getString(1);
        CmsUUID structureId = new CmsUUID(resultSet.getString(2));
        int state = resultSet.getInt(3);
        long dateChanged = resultSet.getLong(4);
        String locale = resultSet.getString(5);
        return new CmsUrlNameMappingEntry(name, structureId, state, dateChanged, locale);
    }
1283727
private function getSQLForJoins($fromAlias, array &$knownAliases)
    {
        $sql = '';

        if (isset($this->sqlParts['join'][$fromAlias])) {
            foreach ($this->sqlParts['join'][$fromAlias] as $join) {
                if (array_key_exists($join['joinAlias'], $knownAliases)) {
                    throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
                }
                $sql                             .= ' ' . strtoupper($join['joinType'])
                    . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
                    . ' ON ' . ((string) $join['joinCondition']);
                $knownAliases[$join['joinAlias']] = true;
            }

            foreach ($this->sqlParts['join'][$fromAlias] as $join) {
                $sql .= $this->getSQLForJoins($join['joinAlias'], $knownAliases);
            }
        }

        return $sql;
    }
1178917
private NodeData createNodeData(ResultSet resultSet) throws SQLException, IllegalPathException, IllegalNameException
   {
      String nodeId = getIdentifier(resultSet, DBConstants.COLUMN_ID);
      int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
      int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
      QPath path = QPath.makeChildPath(QPath.parse("[]unknown-parent-node-remover"), getQPathEntry(resultSet));

      return new TransientNodeData(path, nodeId, version, Constants.NT_UNSTRUCTURED, new InternalQName[0], orderNum,
         Constants.ROOT_UUID, new AccessControlList());
   }
1165835
public static void closeResultSetStatement(ResultSet resultSet, String sql) {
		if (resultSet != null) {
			try {
				resultSet.getStatement().close();
			} catch (SQLException e) {
				log.log(Level.WARNING, "Failed to close SQL ResultSet: " + sql,
						e);
			}
		}
	}
980569
public static SQLQuery<Tuple> selectDistinct(Expression<?>... exprs) {
        return new SQLQuery<Void>().select(exprs).distinct();
    }
253467
protected CmsHistoryProject internalCreateProject(ResultSet res, List<String> resources) throws SQLException {

        String ou = CmsOrganizationalUnit.removeLeadingSeparator(
            res.getString(m_sqlManager.readQuery("C_PROJECTS_PROJECT_OU_0")));
        CmsUUID publishedById = new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROJECT_PUBLISHED_BY_0")));
        CmsUUID userId = new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROJECTS_USER_ID_0")));
        return new CmsHistoryProject(
            res.getInt(m_sqlManager.readQuery("C_PROJECTS_PUBLISH_TAG_0")),
            new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROJECTS_PROJECT_ID_0"))),
            ou + res.getString(m_sqlManager.readQuery("C_PROJECTS_PROJECT_NAME_0")),
            res.getString(m_sqlManager.readQuery("C_PROJECTS_PROJECT_DESCRIPTION_0")),
            userId,
            new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROJECTS_GROUP_ID_0"))),
            new CmsUUID(res.getString(m_sqlManager.readQuery("C_PROJECTS_MANAGERGROUP_ID_0"))),
            res.getLong(m_sqlManager.readQuery("C_PROJECTS_DATE_CREATED_0")),
            CmsProject.CmsProjectType.valueOf(res.getInt(m_sqlManager.readQuery("C_PROJECTS_PROJECT_TYPE_0"))),
            res.getLong(m_sqlManager.readQuery("C_PROJECT_PUBLISHDATE_0")),
            publishedById,
            resources);
    }
500222
@Override
	public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
			final ResultSet resultSet) {
		if (skipFilter) {
			return resultSet;
		}

		try {
			return new SecretResultSet(resultSet, this.createDecryptor(), getCryptColumnNames(), getCharset());
		} catch (Exception ex) {
			LOG.error("Failed to create SecretResultSet.", ex);
		}
		return resultSet;
	}
468276
@Override
	public Map<String, Object> createRecord(final ResultSet rs) throws SQLException {
		ResultSetMetaData rsmd = rs.getMetaData();
		int columnCount = rsmd.getColumnCount();
		Map<String, Object> record = new LinkedHashMap<>(columnCount);
		for (int i = 1; i <= columnCount; i++) {
			record.put(caseFormat.convert(rsmd.getColumnLabel(i)), getValue(rs, rsmd, i));
		}
		return record;
	}
1306935
public List<Object[]> select(Sql sql) throws SQLException {
		
		long start =  System.currentTimeMillis();
		
		if (sql.validate() == false) {
			return null;
		}
		
		List<Object[]> dataList = null;
		
		if (sql.isSelect()) {
			
			ResultSet rs = null;
			PreparedStatement stmt = null;

			try {
				stmt = this.createStatment(conn, sql);
				rs = stmt.executeQuery();
				
				dataList = getResultSet(rs);

			} catch (SQLException e) {
				throw e;
			} finally {
				try {
					if (rs != null && rs.isClosed() == false) {
						rs.close();
					}
					if (stmt != null && stmt.isClosed() == false) {
						stmt.close();
					}
				} catch (SQLException e) {
					throw e;
				}
			}
		}
		
		logger.debug(String.format("Execute %s used %d ms", sql.getSql(), System.currentTimeMillis() - start));
		
		return dataList;
	}
82191
private Post.Builder postFromResultSet(final ResultSet rs) throws SQLException {
      Post.Builder post = Post.newBuilder();
      post.setId(rs.getLong(1));
      post.setAuthorId(rs.getLong(2));

      Timestamp ts = rs.getTimestamp(3);
      post.setPublishTimestamp(ts != null ? ts.getTime() : 0L);

      post.setContent(Strings.emptyToNull(rs.getString(4)));
      post.setTitle(Strings.emptyToNull(rs.getString(5)));
      post.setExcerpt(Strings.emptyToNull(rs.getString(6)));
      post.setStatus(Post.Status.fromString(rs.getString(7)));
      post.setSlug(Strings.emptyToNull(rs.getString(8)));

      ts = rs.getTimestamp(9);
      post.setModifiedTimestamp(ts != null ? ts.getTime() : 0L);

      post.setParentId(rs.getLong(10));
      post.setGUID(Strings.emptyToNull(rs.getString(11)));
      post.setType(Post.Type.fromString(rs.getString(12)));
      post.setMimeType(rs.getString(13));
      return post;
   }
660768
public Query execute(PageContext pc, SQL sql, Selects selects, int maxrows) throws PageException {
	Column[] orders = selects.getOrderbys();
	Select[] arrSelects = selects.getSelects();

	QueryImpl target = new QueryImpl(new Collection.Key[0], 0, "query", sql);

	for (int i = 0; i < arrSelects.length; i++) {
	    arrSelects[i].getFroms();
	    Column[] froms = arrSelects[i].getFroms();
	    if (froms.length > 1) throw new DatabaseException("can only work with single tables yet", null, sql, null);
	    executeSingle(pc, arrSelects[i], getSingleTable(pc, froms[0]), target, arrSelects.length > 1 ? -1 : maxrows, sql, orders.length > 0);
	}

	// Order By
	if (orders.length > 0) {
	    order(target, orders);
	    if (maxrows > -1) target.cutRowsTo(maxrows);
	}
	// Distinct
	if (selects.isDistinct()) {
	    order(target, selects.getDistincts()); // order to filter
	    // print.e(selects.getDistincts());
	    Key[] _keys = target.getColumnNames();
	    QueryColumn[] columns = new QueryColumn[_keys.length];
	    for (int i = 0; i < columns.length; i++) {
		columns[i] = target.getColumn(_keys[i]);
	    }

	    int i;
	    Object l, r;
	    outer: for (int row = target.getRecordcount(); row > 1; row--) {
		for (i = 0; i < columns.length; i++) {
		    l = columns[i].get(row, null);
		    r = columns[i].get(row - 1, null);
		    if (l == null || r == null) {
			if (l != r) continue outer;
		    }
		    else if (!Operator.equals(l, r, true)) continue outer;
		}
		target.removeRow(row);
	    }
	}
	order(target, orders);

	return target;
    }