Move the physical binary data to this SQL parameter row.
@param resultset The resultset to get the SQL data from.
@param iColumn the column in the resultset that has my data.
@exception SQLException From SQL calls.
542354
public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException
    {
        double dResult = resultset.getDouble(iColumn);
        if (resultset.wasNull())
            this.setString(Constants.BLANK, false, DBConstants.READ_MOVE);  // Null value
        else
        {
            if ((!this.isNullable()) && (dResult == Double.NaN))
                this.setString(Constants.BLANK, false, DBConstants.READ_MOVE);  // Null value
            else
                this.setValue(dResult, false, DBConstants.READ_MOVE);
        }
    }
843093
public static <T> ExceptionalStream<T, SQLException> rows(final ResultSet resultSet, final String columnName) {
        N.checkArgNotNull(resultSet, "resultSet");
        N.checkArgNotNull(columnName, "columnName");

        return rows(resultSet, getColumnIndex(resultSet, columnName));
    }
655608
@Override
	public void updateNClob(final int columnIndex, final NClob nClob) throws SQLException {
		wrapped.updateNClob(columnIndex, nClob);
	}
6170
public static ResultSet callQuery(Connection conn, String sql, Object... params) throws SQLException {
		CallableStatement proc = null;
		try {
			proc = StatementUtil.prepareCall(conn, sql, params);
			return proc.executeQuery();
		} finally {
			DbUtil.close(proc);
		}
	}
1027195
public int dataToFields(Rec record) throws DBException
    {
        m_iColumn = 1;
        int iErrorCode = super.dataToFields(record);

        KeyArea keyArea = this.getRecord().getKeyArea(0); // Primary index
        keyArea.setupKeyBuffer(null, DBConstants.TEMP_KEY_AREA);        // Save keys for possible update/delete
        if (this.getResultSetType() != DBConstants.SQL_SELECT_TYPE)
            if (CLEANUP_STATEMENTS)
                this.setResultSet(null, this.getResultSetType());  // Close this statement

        return iErrorCode;
    }
533460
@Override
    public void setNClob(int parameterIndex, NClob value) throws SQLException
    {
        checkParameterBounds(parameterIndex);
        throw SQLError.noSupport();
    }
297081
@Override
    public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
    {
        checkClosed();
        this.sysCatalog.setString(1, "COLUMNS");
        JDBC4ResultSet res = (JDBC4ResultSet) this.sysCatalog.executeQuery();
        VoltTable vtable = res.getVoltTable().clone(0);

        // If no pattern is specified, default to matching any/all.
        if (tableNamePattern == null || tableNamePattern.length() == 0)
        {
            tableNamePattern = "%";
        }
        Pattern table_pattern = computeJavaPattern(tableNamePattern);

        if (columnNamePattern == null || columnNamePattern.length() == 0)
        {
            columnNamePattern = "%";
        }
        Pattern column_pattern = computeJavaPattern(columnNamePattern);

        // Filter columns based on table name and column name
        while (res.next()) {
            Matcher table_matcher = table_pattern.matcher(res.getString("TABLE_NAME"));
            if (table_matcher.matches())
            {
                Matcher column_matcher = column_pattern.matcher(res.getString("COLUMN_NAME"));
                if (column_matcher.matches())
                {
                    vtable.addRow(res.getRowData());
                }
            }
        }

        return new JDBC4ResultSet(this.sysCatalog, vtable);
    }
1030867
public static void closeResultSet(ResultSet resultSet)
        throws InternalErrorException {

        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
                throw new InternalErrorException(e);
            }
        }

    }
1226817
public void moveSQLToField(ResultSet resultset, int iColumn) throws SQLException
    {
        int sResult = resultset.getInt(iColumn);
        if (resultset.wasNull())
            this.setString(Constants.BLANK, false, DBConstants.READ_MOVE);  // Null value
        else
        {
            if ((!this.isNullable()) && (sResult == NAN))
                this.setString(Constants.BLANK, false, DBConstants.READ_MOVE);  // Null value
            else
                this.setValue(sResult, false, DBConstants.READ_MOVE);
        }
    }
1047872
public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException
    {
        if (this.isNull())
        {
            if ((this.isNullable()) && (iType != DBConstants.SQL_SELECT_TYPE))
                statement.setNull(iParamColumn, Types.FLOAT);
            else
                statement.setFloat(iParamColumn, Float.NaN);
        }
        else
        {
            if (DBConstants.FALSE.equals(this.getRecord().getTable().getDatabase().getProperties().get(SQLParams.FLOAT_XFER_SUPPORTED)))    // HACK for Access
                super.getSQLFromField(statement, iType, iParamColumn);
            else
                statement.setFloat(iParamColumn, (float)this.getValue());
        }
    }
1013563
public Statement createStatement(final int resultSetType, 
                                     final int resultSetConcurrency, 
                                     final int resultSetHoldability) 
        throws SQLException {

        if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
            throw new SQLFeatureNotSupportedException("Unsupported result set holdability");
        } // end of if

        return createStatement(resultSetType, resultSetConcurrency);
    }
722824
public static Table read(ResultSet resultSet) throws SQLException {

        ResultSetMetaData metaData = resultSet.getMetaData();
        Table table = Table.create();

        // Setup the columns and add to the table
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            String name = metaData.getColumnName(i);
            int columnType = metaData.getColumnType(i);
            ColumnType type = SQL_TYPE_TO_TABLESAW_TYPE.get(columnType);
            // Try to improve on the initial type assigned to 'type' to minimize size/space of type needed.
            // For all generic numeric columns inspect closer, checking the precision and 
            // scale to more accurately determine the appropriate java type to use.
            if (columnType == Types.NUMERIC || columnType == Types.DECIMAL) {
                int s = metaData.getScale(i);
                // When scale is 0 then column is a type of integer
                if (s == 0) {
                    int p = metaData.getPrecision(i);
/* Mapping to java integer types based on integer precision defined:

Java type           TypeMinVal              TypeMaxVal          p               MaxIntVal
-----------------------------------------------------------------------------------------
byte, Byte:         -128                    127                 NUMBER(2)       99
short, Short:       -32768                  32767               NUMBER(4)       9_999
int, Integer:       -2147483648             2147483647          NUMBER(9)       999_999_999 
long, Long:         -9223372036854775808    9223372036854775807 NUMBER(18)      999_999_999_999_999_999

*/
                    // Start with SHORT (since ColumnType.BYTE isn't supported yet)
                    // and find the smallest java integer type that fits
                    if (p <= 4) {
                        type = ShortColumnType.instance();
                    } else if (p <= 9) {
                        type = ColumnType.INTEGER;
                    } else if (p <= 18) {
                        type = ColumnType.LONG;
                    }
                } else { // s is not zero, so a decimal value is expected. First try float, then double
                    if (s <= 7) {
                        type = ColumnType.FLOAT;
                    } else if (s <= 16) {
                        type = ColumnType.DOUBLE;
                    }
                }
            }
            Preconditions.checkState(type != null,
                    "No column type found for %s as specified for column %s", metaData.getColumnType(i), name);

            Column<?> newColumn = type.create(name);
            table.addColumns(newColumn);
        }

        // Add the rows
        while (resultSet.next()) {
            for (int i = 1; i <= metaData.getColumnCount(); i++) {
                Column<?> column = table.column(i - 1); // subtract 1 because results sets originate at 1 not 0
                if (column instanceof ShortColumn) {
                    column.appendObj(resultSet.getShort(i));
                } else if (column instanceof IntColumn) {
                    column.appendObj(resultSet.getInt(i));
                } else if (column instanceof LongColumn) {
                    column.appendObj(resultSet.getLong(i));
                } else if (column instanceof FloatColumn) {
                    column.appendObj(resultSet.getFloat(i));
                } else if (column instanceof DoubleColumn) {
                    column.appendObj(resultSet.getDouble(i));
                } else {
                    column.appendObj(resultSet.getObject(i));
                }
            }
        }
        return table;
    }
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);
    }
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());
        }
      }
    }
  }
124749
boolean executeInternal(String sql,
                          Map<String, ParameterBindingDTO> parameterBindings)
  throws SQLException
  {
    raiseSQLExceptionIfStatementIsClosed();
    connection.injectedDelay();

    logger.debug("execute: {}", sql);

    String trimmedSql = sql.trim();

    if (trimmedSql.length() >= 20
        && trimmedSql.toLowerCase().startsWith("set-sf-property"))
    {
      // deprecated: sfsql
      executeSetProperty(sql);
      return false;
    }

    SFBaseResultSet sfResultSet;
    try
    {
      sfResultSet = sfStatement.execute(sql, parameterBindings,
                                        SFStatement.CallingMethod.EXECUTE);
      sfResultSet.setSession(this.connection.getSfSession());
      if (resultSet != null)
      {
        openResultSets.add(resultSet);
      }
      resultSet = new SnowflakeResultSetV1(sfResultSet, this);
      queryID = sfResultSet.getQueryId();

      // Legacy behavior treats update counts as result sets for single-
      // statement execute, so we only treat update counts as update counts
      // if JDBC_EXECUTE_RETURN_COUNT_FOR_DML is set, or if a statement
      // is multi-statement
      if (!sfResultSet.getStatementType().isGenerateResultSet() &&
          (connection.getSfSession().isExecuteReturnCountForDML() ||
           sfStatement.hasChildren()))
      {
        updateCount = ResultUtil.calculateUpdateCount(sfResultSet);
        if (resultSet != null)
        {
          openResultSets.add(resultSet);
        }
        resultSet = null;
        return false;
      }

      updateCount = NO_UPDATES;
      return true;
    }
    catch (SFException ex)
    {
      throw new SnowflakeSQLException(ex.getCause(),
                                      ex.getSqlState(), ex.getVendorCode(), ex.getParams());
    }
  }
885561
static public List<ColumnMetaData> createList(ResultSetMetaData m) throws SQLException{
		List<ColumnMetaData> result = new ArrayList<ColumnMetaData>(m.getColumnCount());
		for (int i = 1; i <= m.getColumnCount(); i ++){
			ColumnMetaData cm = new ColumnMetaData(m, i);
			result.add(cm);
		}
		return result;
	}
523263
public void write(ProgressVisitor progress, ResultSet resultSet, File file) throws SQLException, IOException {
        write(progress, resultSet, file, null);
    }