net.snowflake.client.core

## Class SFStatement

- java.lang.Object
- - net.snowflake.client.core.SFBaseStatement
  - - net.snowflake.client.core.SFStatement

    public class SFStatement
    extends SFBaseStatement

Snowflake statement

### Nested Class Summary

### Nested classes/interfaces inherited from class net.snowflake.client.core.SFBaseStatement

`SFBaseStatement.CallingMethod`

### Field Summary

### Fields inherited from class net.snowflake.client.core.SFBaseStatement

`MAX_STATEMENT_PARAMETERS, queryTimeout, statementParametersMap`

### Constructor Summary

Constructors
Constructor and Description
`SFStatement(SFSession session)`

### Method Summary

All Methods Instance Methods Concrete Methods
`SFBaseResultSet` `asyncExecute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller)` Execute sql asynchronously.
`void` `cancel()` Aborts the statement.
`void` `close()` Closes the statement.
`SFStatementMetaData` `describe(String sql)` Describe a statement
`SFBaseResultSet` `execute(String sql, boolean asyncExec, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller)` Execute sql
`SFBaseResultSet` `execute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller)` Executes the given SQL string.
`Object` `executeHelper(String sql, String mediaType, Map<String,ParameterBindingDTO> bindValues, boolean describeOnly, boolean internal, boolean asyncExec)` A helper method to build URL and submit the SQL to snowflake for exec
`long` `getConservativeMemoryLimit()`
`int` `getConservativePrefetchThreads()`
`boolean` `getMoreResults()`
`boolean` `getMoreResults(int current)` Sets the result set to the next one, if available.
`SFBaseResultSet` `getResultSet()` Retrieves the current result as a ResultSet, if any.
`SFBaseSession` `getSFBaseSession()` Returns the SFBaseSession associated with this SFBaseStatement.
`boolean` `hasChildren()` If this is a multi-statement, i.e., has child results.

### Methods inherited from class net.snowflake.client.core.SFBaseStatement

`addProperty, executeSetProperty`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SFStatement

    public SFStatement(SFSession session)

### Method Detail

#### describe

    public SFStatementMetaData describe(String sql)
                                 throws SFException,
                                        SQLException

Describe a statement

Specified by:
  `describe` in class `SFBaseStatement`
Parameters:
  `sql` - statement
Returns:
  metadata of statement including result set metadata and binding information
Throws:
  `SQLException` - if connection is already closed
  `SFException` - if result set is null

#### executeHelper

    public Object executeHelper(String sql,
                                String mediaType,
                                Map<String,ParameterBindingDTO> bindValues,
                                boolean describeOnly,
                                boolean internal,
                                boolean asyncExec)
                         throws SnowflakeSQLException,
                                SFException

A helper method to build URL and submit the SQL to snowflake for exec

Parameters:
  `sql` - sql statement
  `mediaType` - media type
  `bindValues` - map of binding values
  `describeOnly` - whether only show the result set metadata
  `internal` - run internal query not showing up in history
Returns:
  raw json response
Throws:
  `SFException` - if query is canceled
  `SnowflakeSQLException` - if query is already running

#### getConservativePrefetchThreads

    public int getConservativePrefetchThreads()

Specified by:
  `getConservativePrefetchThreads` in class `SFBaseStatement`
Returns:
  conservative prefetch threads before fetching results

#### getConservativeMemoryLimit

    public long getConservativeMemoryLimit()

Specified by:
  `getConservativeMemoryLimit` in class `SFBaseStatement`
Returns:
  conservative memory limit before fetching results

#### execute

    public SFBaseResultSet execute(String sql,
                                   Map<String,ParameterBindingDTO> parametersBinding,
                                   SFBaseStatement.CallingMethod caller)
                            throws SQLException,
                                   SFException

Description copied from class: `SFBaseStatement`
Executes the given SQL string.

Specified by:
  `execute` in class `SFBaseStatement`
Parameters:
  `sql` - The SQL string to execute, synchronously.
  `parametersBinding` - parameters to bind
  `caller` - the JDBC interface method that called this method, if any
Returns:
  whether there is result set or not
Throws:
  `SQLException` - if failed to execute sql
  `SFException` - exception raised from Snowflake components

#### execute

    public SFBaseResultSet execute(String sql,
                                   boolean asyncExec,
                                   Map<String,ParameterBindingDTO> parametersBinding,
                                   SFBaseStatement.CallingMethod caller)
                            throws SQLException,
                                   SFException

Execute sql

Parameters:
  `sql` - sql statement.
  `parametersBinding` - parameters to bind
  `caller` - the JDBC interface method that called this method, if any
Returns:
  whether there is result set or not
Throws:
  `SQLException` - if failed to execute sql
  `SFException` - exception raised from Snowflake components
  `SQLException` - if SQL error occurs

#### close

    public void close()

Description copied from class: `SFBaseStatement`
Closes the statement. Open result sets are closed, connections are terminated, state is cleared, etc.

Specified by:
  `close` in class `SFBaseStatement`

#### cancel

    public void cancel()
                throws SFException,
                       SQLException

Description copied from class: `SFBaseStatement`
Aborts the statement.

Specified by:
  `cancel` in class `SFBaseStatement`
Throws:
  `SFException` - if the statement is already closed.
  `SQLException` - if there are server-side errors from trying to abort.

#### getSFBaseSession

    public SFBaseSession getSFBaseSession()

Description copied from class: `SFBaseStatement`
Returns the SFBaseSession associated with this SFBaseStatement.

Specified by:
  `getSFBaseSession` in class `SFBaseStatement`

#### getMoreResults

    public boolean getMoreResults()
                           throws SQLException

Throws:
  `SQLException`

#### getMoreResults

    public boolean getMoreResults(int current)
                           throws SQLException

Description copied from class: `SFBaseStatement`
Sets the result set to the next one, if available.

Specified by:
  `getMoreResults` in class `SFBaseStatement`
Parameters:
  `current` - What to do with the current result. One of Statement.CLOSE_CURRENT_RESULT, Statement.CLOSE_ALL_RESULTS, or Statement.KEEP_CURRENT_RESULT
Returns:
  true if there is a next result and it's a result set false if there are no more results, or there is a next result and it's an update count
Throws:
  `SQLException` - if something fails while getting the next result

#### getResultSet

    public SFBaseResultSet getResultSet()

Description copied from class: `SFBaseStatement`
Retrieves the current result as a ResultSet, if any. This is invoked by SnowflakeStatement and should return an SFBaseResultSet, which is then wrapped in a SnowflakeResultSet.

Specified by:
  `getResultSet` in class `SFBaseStatement`

#### hasChildren

    public boolean hasChildren()

Description copied from class: `SFBaseStatement`
If this is a multi-statement, i.e., has child results.

Specified by:
  `hasChildren` in class `SFBaseStatement`

#### asyncExecute

    public SFBaseResultSet asyncExecute(String sql,
                                        Map<String,ParameterBindingDTO> parametersBinding,
                                        SFBaseStatement.CallingMethod caller)
                                 throws SQLException,
                                        SFException

Description copied from class: `SFBaseStatement`
Execute sql asynchronously. Note that at a minimum, this does not have to be supported; if executeAsyncQuery() is called from SnowflakeStatement and the SFConnectionHandler's supportsAsyncQuery() returns false, an exception is thrown. If this is un-implemented, then supportsAsyncQuery() should return false.

Specified by:
  `asyncExecute` in class `SFBaseStatement`
Parameters:
  `sql` - sql statement.
  `parametersBinding` - parameters to bind
  `caller` - the JDBC interface method that called this method, if any
Returns:
  whether there is result set or not
Throws:
  `SQLException` - if failed to execute sql
  `SFException` - exception raised from Snowflake components