Creates a blog from a result set.
@param rs The result set.
@return The blog.
@throws SQLException on database error.
553641
private Blog blogFromResultSet(final ResultSet rs) throws SQLException {

      long registeredTimestamp = 0L;
      long lastUpdatedTimestamp = 0L;

      try {
         registeredTimestamp = rs.getTimestamp(5).getTime();
      } catch(SQLException se) {
         //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
         registeredTimestamp = 0L;
      }

      try {
         lastUpdatedTimestamp = rs.getTimestamp(6).getTime();
      } catch(SQLException se) {
         //Deal with possible java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
         lastUpdatedTimestamp = 0L;
      }

      return new Blog(rs.getLong(1), rs.getLong(2), rs.getString(3), rs.getString(4), registeredTimestamp, lastUpdatedTimestamp);
   }
1061657
int print(ResultSet rs, DispatchCallback callback) throws SQLException {
    String format = getOpts().getOutputFormat();
    OutputFormat f = getOutputFormats().get(format);
    if ("csv".equals(format)) {
      final SeparatedValuesOutputFormat csvOutput =
          (SeparatedValuesOutputFormat) f;
      if ((csvOutput.separator == null && getOpts().getCsvDelimiter() != null)
          || (csvOutput.separator != null
              && !csvOutput.separator.equals(getOpts().getCsvDelimiter())
              || csvOutput.quoteCharacter
                  != getOpts().getCsvQuoteCharacter())) {
        f = new SeparatedValuesOutputFormat(this,
            getOpts().getCsvDelimiter(), getOpts().getCsvQuoteCharacter());
        Map<String, OutputFormat> updFormats =
            new HashMap<>(getOutputFormats());
        updFormats.put("csv", f);
        updateOutputFormats(updFormats);
      }
    }

    Rows rows;
    if (getOpts().getIncremental()) {
      rows = new IncrementalRows(this, rs, callback);
    } else {
      rows = new BufferedRows(this, rs);
    }

    return f.print(rows);
  }
225873
@Override
    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
        // return new
        // NativeStatement(internalConn.createStatement(resultSetType,
        // resultSetConcurrency), this);
        return internalConn.createStatement(resultSetType, resultSetConcurrency);
    }
534628
public static void sqlRS(Connection conn, String sql, Consumer<ResultSet> consumer) {
        try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
            consumer.accept(rs);
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        }
    }
5915
public QueryResults execute() throws JspCoreException, SQLException {

        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        ;
        QueryResults qs = null;
        // verify all parameters
        verify();

        // invoke the compute method of QueryResults passing it the SQL resultset
        // the QueryResults will get all the data from the result set and cache it in
        // its private datastructures
        try {
            conn = getJdbcConnection();
            //conn = DriverManager.getConnection(url,user,passwd);
            stmt = conn.createStatement();
            int mrows = getMaxRows();
            if (mrows > 0)
                stmt.setMaxRows(mrows);
            rs = stmt.executeQuery(getQueryString());
            qs = new QueryResults();
            qs.compute(rs);
        }
        catch (SQLException e) {
            //com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.execute", "73", this);
            throw e;
        }
        finally { // always free up database resources
            if (rs != null)
                rs.close();
            if (stmt != null)
                stmt.close();
            if (conn != null)
                conn.close();
        }
        setResults(qs);
        return qs;
    }
348681
private Object getValue(final ResultSet rs, final ResultSetMetaData rsmd, final int columnIndex)
			throws SQLException {
		JavaType javaType = this.dialect.getJavaType(rsmd.getColumnType(columnIndex),
				rsmd.getColumnTypeName(columnIndex));
		return this.mapperManager.getValue(javaType, rs, columnIndex);
	}
466414
public final Element mapRow(final ResultSet rs, final String columnName) throws SQLException {
        final Element element = new Element();
        List<String> l;
        try {
            l = ParseUtils.postgresROW2StringList(rs.getString(columnName));
        } catch (RowParserException e) {
            throw new SQLException(e);
        }

        element.setRowList(l);
        return element;
    }
811457
public static String fromResultSet(ResultSet resultSet) throws SQLException {
    if (resultSet == null) throw new NullPointerException("resultSet == null");
    if (!resultSet.isBeforeFirst()) throw new IllegalStateException("Result set not at first.");

    List<String> headers = new ArrayList<>();
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    for (int column = 0; column < columnCount; column++) {
      headers.add(resultSetMetaData.getColumnName(column + 1));
    }

    List<String[]> data = new ArrayList<>();
    while (resultSet.next()) {
      String[] rowData = new String[columnCount];
      for (int column = 0; column < columnCount; column++) {
        rowData[column] = resultSet.getString(column + 1);
      }
      data.add(rowData);
    }

    String[] headerArray = headers.toArray(new String[headers.size()]);
    String[][] dataArray = data.toArray(new String[data.size()][]);
    return FlipTable.of(headerArray, dataArray);
  }
494027
@Override
    public Statement createStatement() throws SQLException
    {
        checkClosed();
        try
        {
            return new JDBC4Statement(this);
        }
        catch(Exception x)
        {
            throw SQLError.get(x);
        }
    }
765972
public List<Map<String, Object>> convertAllToMaps(ResultSet rs) throws SQLException{
		return convertAllToMaps(rs, null);
	}
640709
@Override
	public DataRow create(Object rs, int index)
	{
		JavaBean.acceptVisitor(rs, this);
		
		DataRow dataRow = this.getDataRow();
		
		dataRow.setRowNum(index);
		
		this.clear();
		
		return dataRow;
	}
311478
public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
        // spring's : Object mappedObject = BeanUtils.instantiateClass(this.mappedClass);
        // jade's : private Object instantiateClass(this.mappedClass);
        // why: 经过简单的笔记本测试，mappedClass.newInstrance性能比BeanUtils.instantiateClass(mappedClass)快1个数量级
        Object mappedObject = instantiateClass(this.mappedClass);
        BeanWrapper bw = new BeanWrapperImpl(mappedObject);

        ResultSetMetaData rsmd = rs.getMetaData();
        int columnCount = rsmd.getColumnCount();

        boolean warnEnabled = logger.isWarnEnabled();
        boolean debugEnabled = logger.isDebugEnabled();
        Set<String> populatedProperties = (checkProperties ? new HashSet<String>() : null);

        for (int index = 1; index <= columnCount; index++) {
            String column = JdbcUtils.lookupColumnName(rsmd, index).toLowerCase();
            PropertyDescriptor pd = this.mappedFields.get(column);
            if (pd != null) {
                try {
                    Object value = JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
                    if (debugEnabled && rowNumber == 0) {
                        logger.debug("Mapping column '" + column + "' to property '" + pd.getName()
                                + "' of type " + pd.getPropertyType());
                    }
                    bw.setPropertyValue(pd.getName(), value);
                    if (populatedProperties != null) {
                        populatedProperties.add(pd.getName());
                    }
                } catch (NotWritablePropertyException ex) {
                    throw new DataRetrievalFailureException("Unable to map column " + column
                            + " to property " + pd.getName(), ex);
                }
            } else {
                if (checkColumns) {
                    throw new InvalidDataAccessApiUsageException("Unable to map column '" + column
                            + "' to any properties of bean " + this.mappedClass.getName());
                }
                if (warnEnabled && rowNumber == 0) {
                    logger.warn("Unable to map column '" + column + "' to any properties of bean "
                            + this.mappedClass.getName());
                }
            }
        }

        if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) {
            throw new InvalidDataAccessApiUsageException(
                    "Given ResultSet does not contain all fields "
                            + "necessary to populate object of class [" + this.mappedClass + "]: "
                            + this.mappedProperties);
        }

        return mappedObject;
    }
484494
public Object convertToDynamicBean(ResultSet rs) throws SQLException{
		ResultSetMetaData rsmd = rs.getMetaData();
		
		Map<String, ColumnMetaData> columnToPropertyMappings = createColumnToPropertyMappings(rsmd);
		
		Class<?> beanClass = reuseOrBuildBeanClass(rsmd, columnToPropertyMappings);
		BeanProcessor beanProcessor = new BeanProcessor(simpleColumnToPropertyMappings(columnToPropertyMappings));
		return beanProcessor.toBean(rs, beanClass);
	}
1297730
private static <T> T executeQuery(PreparedStatement ps, RsHandler<T> rsh) throws SQLException {
		ResultSet rs = null;
		try {
			rs = ps.executeQuery();
			return rsh.handle(rs);
		} finally {
			DbUtil.close(rs);
		}
	}
224693
public void closeResultSet() throws SQLException {
    if (rs != null) {
      if (!rs.isClosed()) {
        rs.close();
      }
      rs = null;
    }
  }
492903
public List extract(ResultSet rs) throws Exception {
		ResultSetMetaData meta = rs.getMetaData();
		int count = meta.getColumnCount();
		List ret = new ArrayList();
		while (rs.next()) {
			Map map = new LinkedHashMap(count);
			for (int i = 1; i <= count; i++) {
				map.put(meta.getColumnName(i), rs.getObject(i));
			}
			ret.add(map);
		}
		return ret;
	}
1335095
public ColumnResult<SqlResultSetMapping<T>> getOrCreateColumnResult()
   {
      List<Node> nodeList = childNode.get("column-result");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new ColumnResultImpl<SqlResultSetMapping<T>>(this, "column-result", childNode, nodeList.get(0));
      }
      return createColumnResult();
   }