Converts ResultSet current row into {@link QueryParameters}. Return value is handled by {@link TypeHandler}

@param rs ResultSet which would be read
@return converted ResultSet current row
@throws SQLException
331390
private QueryParameters convertResultSetCurrentLine(ResultSet rs) throws SQLException {
        ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();
        String columnName = null;
        QueryParameters result = new QueryParameters();

        for (int i = 1; i <= cols; i++) {

            columnName = rsmd.getColumnLabel(i);
            if (null == columnName || 0 == columnName.length()) {
                columnName = rsmd.getColumnName(i);
            }

            result.set(columnName, rs.getObject(i));
            result.updatePosition(columnName, i - 1);
        }

        if (result != null) {
            result = typeHandler.processOutput(stmt, result);
        }

        return result;
    }
1086255
public static String getOjbClassName(ResultSet rs)
    {
        try
        {
            return rs.getString(OJB_CLASS_COLUMN);
        }
        catch (SQLException e)
        {
            return null;
        }
    }
196121
private IEntityLock instanceFromResultSet(java.sql.ResultSet rs)
            throws SQLException, LockingException {
        Integer entityTypeID = rs.getInt(1);
        Class entityType = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(entityTypeID);
        String key = rs.getString(2);
        int lockType = rs.getInt(3);
        Timestamp ts = rs.getTimestamp(4);
        String lockOwner = rs.getString(5);

        return newInstance(entityType, key, lockType, ts, lockOwner);
    }
705471
public static <T> ExceptionalStream<T, SQLException> rows(final ResultSet resultSet, final Try.Function<ResultSet, T, SQLException> recordGetter) {
        N.checkArgNotNull(resultSet, "resultSet");
        N.checkArgNotNull(recordGetter, "recordGetter");

        final ExceptionalIterator<T, SQLException> iter = new ExceptionalIterator<T, SQLException>() {
            private boolean hasNext;

            @Override
            public boolean hasNext() throws SQLException {
                if (hasNext == false) {
                    hasNext = resultSet.next();
                }

                return hasNext;
            }

            @Override
            public T next() throws SQLException {
                if (hasNext() == false) {
                    throw new NoSuchElementException();
                }

                hasNext = false;

                return recordGetter.apply(resultSet);
            }

            @Override
            public void skip(long n) throws SQLException {
                N.checkArgNotNegative(n, "n");

                final long m = hasNext ? n - 1 : n;

                JdbcUtil.skip(resultSet, m);

                hasNext = false;
            }
        };

        return newStream(iter);
    }
248915
public static void close(ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException ex) {
                logger.error("", ex);
            }
        }
    }
208764
public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Object... params) throws SQLException {
		PreparedStatement ps = null;
		try {
			ps = StatementUtil.prepareStatement(conn, sql, params);
			return executeQuery(ps, rsh);
		} finally {
			DbUtil.close(ps);
		}
	}
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;
	}
834673
public ResultSetMetaData getMetaData() throws SQLException {
        if (tc.isEntryEnabled())
            Tr.entry(this, tc, "getMetaData");

        // First, check if a ResultSetMetaData wrapper for this ResultSet already exists.

        ResultSetMetaData rsetMData = null;

        try // get a meta data
        {
            rsetMData = rsetImpl.getMetaData();
        } catch (SQLException ex) {
            FFDCFilter.processException(ex, "com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getMetaData", "1579", this);
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "getMetaData", "Exception");
            throw WSJdbcUtil.mapException(this, ex);
        } catch (NullPointerException nullX) {
            // No FFDC code needed; we might be closed.
            if (tc.isEntryEnabled())
                Tr.exit(this, tc, "getMetaData", "Exception");
            throw runtimeXIfNotClosed(nullX);
        }

        if (tc.isEntryEnabled())
            Tr.exit(this, tc, "getMetaData", rsetMData);
        return rsetMData;
    }
673248
public static void closeResultSet(ResultSet rs){
		if (rs != null) {
			try {
				rs.close();
			} catch (Exception e) {
				log.warn("Exception when closing database result set.", e);
			}
		}
	}
1283099
public <T> T page(Connection conn, Collection<String> fields, Entity where, int pageNumber, int numPerPage, RsHandler<T> rsh) throws SQLException {
		return page(conn, fields, where, new Page(pageNumber, numPerPage), rsh);
	}
380037
public static void closeResultSet(ResultSet rs) {
        try {
            if (rs != null && !rs.isClosed()) {
                rs.close();
            }
        } catch (SQLException ex) {
            LOGGER.trace(rs.toString(), ex);
        }
    }
971845
public static Object getFromRS(ResultSet rs, String columnName, Field field)
			throws SQLException{
		if(rs.getObject(columnName) == null) { // 保证null会返回null值
			return null;
		}
		
		Column column = field.getAnnotation(Column.class);
		if(column != null && column.isJSON()) { // 优先处理标记为json的列
			String valStr = rs.getString(columnName);
			if(valStr == null || valStr.trim().isEmpty()) {
				return null;
			}
			String typeName = field.getGenericType().toString();
			try {
				if(!typeName.contains("<")) {
					return OBJECT_MAPPER.readValue(valStr, field.getType());
				} else { // 处理泛型
					JavaType type = parseGenericType(OBJECT_MAPPER.getTypeFactory(), typeName);
					return OBJECT_MAPPER.readValue(valStr, type);
				}
			} catch(Exception e) {
				LOGGER.error("parse column to JSON fail, json:{}, type:{}", valStr, typeName, e);
				return valStr; // 作为string返回，交由上一级处理
			}
		}
		
		Class<?> clazz = field.getType();
		
		if(clazz == Integer.class || clazz == int.class) {
			return rs.getInt(columnName);
		}
		if(clazz == Long.class || clazz == long.class) {
			return rs.getLong(columnName);
		}
		if(clazz == Byte.class || clazz == byte.class) {
			return rs.getByte(columnName);
		}
		if(clazz == byte[].class) {
			return rs.getBytes(columnName);
		}
		if(clazz == Short.class || clazz == short.class) {
			return rs.getShort(columnName);
		}
		if(clazz == Boolean.class || clazz == boolean.class) {
			return rs.getBoolean(columnName);
		}
		if(clazz == Float.class || clazz == float.class) {
			return rs.getFloat(columnName);
		}
		if(clazz == Double.class || clazz == double.class) {
			return rs.getDouble(columnName);
		}
		if(clazz == String.class) {
			return rs.getString(columnName);
		}
		if(clazz == BigDecimal.class) {
			return rs.getBigDecimal(columnName);
		}
		if (clazz == java.sql.Date.class) {
			return rs.getDate(columnName);
		}
		if (clazz == java.sql.Time.class) {
			return rs.getDate(columnName);
		}
		if (clazz == java.sql.Timestamp.class) {
			return rs.getTimestamp(columnName);
		}
		
		return rs.getObject(columnName);
	}
1230361
public ResultSet executeQuery(String sql) throws SQLException {
    if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) {
      return results.getResultSet();
    }
    return SelectResultSet.createEmptyResultSet();
  }
1265632
public static <T extends Entity> T handleRow(T row, int columnCount, ResultSetMetaData meta, ResultSet rs, boolean withMetaInfo) throws SQLException {
		String columnLabel;
		int type;
		for (int i = 1; i <= columnCount; i++) {
			columnLabel = meta.getColumnLabel(i);
			type = meta.getColumnType(i);
			row.put(columnLabel, getColumnValue(rs, columnLabel, type, null));
		}
		if (withMetaInfo) {
			row.setTableName(meta.getTableName(1));
			row.setFieldNames(row.keySet());
		}
		return row;
	}
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);
		}
	}
162299
public <T> T page(Connection conn, Collection<String> fields, Entity where, Page page, RsHandler<T> rsh) throws SQLException {
		checkConn(conn);
		if(null == page){
			return this.find(conn, fields, where, rsh);
		}
		
		final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
		query.setFields(fields);
		query.setPage(page);
		return SqlExecutor.queryAndClosePs(dialect.psForPage(conn, query), rsh);
	}
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);
   }