Package 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 Description SFStatement(SFSession session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SFBaseResultSetasyncExecute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData)Execute sql asynchronously.voidcancel()Aborts the statement.voidclose()Closes the statement.SFPreparedStatementMetaDatadescribe(String sql)Describe a statementSFBaseResultSetexecute(String sql, boolean asyncExec, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData)Execute sqlSFBaseResultSetexecute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData)Executes the given SQL string.ObjectexecuteHelper(String sql, String mediaType, Map<String,ParameterBindingDTO> bindValues, boolean describeOnly, boolean internal, boolean asyncExec, ExecTimeTelemetryData execTimeData)A helper method to build URL and submit the SQL to snowflake for execString[]getChildQueryIds(String queryID)Return an array of child query ID for the given query ID.longgetConservativeMemoryLimit()intgetConservativePrefetchThreads()booleangetMoreResults()booleangetMoreResults(int current)Sets the result set to the next one, if available.SFBaseResultSetgetResultSet()Retrieves the current result as a ResultSet, if any.SFBaseSessiongetSFBaseSession()Returns the SFBaseSession associated with this SFBaseStatement.booleanhasChildren()If this is a multi-statement, i.e., has child results.-
Methods inherited from class net.snowflake.client.core.SFBaseStatement
addProperty, executeSetProperty, getStatementParameters, isFileTransfer
-
-
-
-
Constructor Detail
-
SFStatement
public SFStatement(SFSession session)
-
-
Method Detail
-
describe
public SFPreparedStatementMetaData describe(String sql) throws SFException, SQLException
Describe a statement- Specified by:
describein classSFBaseStatement- Parameters:
sql- statement- Returns:
- metadata of statement including result set metadata and binding information
- Throws:
SQLException- if connection is already closedSFException- if result set is null
-
executeHelper
public Object executeHelper(String sql, String mediaType, Map<String,ParameterBindingDTO> bindValues, boolean describeOnly, boolean internal, boolean asyncExec, ExecTimeTelemetryData execTimeData) throws SnowflakeSQLException, SFException
A helper method to build URL and submit the SQL to snowflake for exec- Parameters:
sql- sql statementmediaType- media typebindValues- map of binding valuesdescribeOnly- whether only show the result set metadatainternal- run internal query not showing up in history- Returns:
- raw json response
- Throws:
SFException- if query is canceledSnowflakeSQLException- if query is already running
-
getConservativePrefetchThreads
public int getConservativePrefetchThreads()
- Specified by:
getConservativePrefetchThreadsin classSFBaseStatement- Returns:
- conservative prefetch threads before fetching results
-
getConservativeMemoryLimit
public long getConservativeMemoryLimit()
- Specified by:
getConservativeMemoryLimitin classSFBaseStatement- Returns:
- conservative memory limit before fetching results
-
getChildQueryIds
public String[] getChildQueryIds(String queryID) throws SQLException
Return an array of child query ID for the given query ID.If the given query ID is for a multiple statements query, it returns an array of its child statements, otherwise, it returns an array to include the given query ID.
- Specified by:
getChildQueryIdsin classSFBaseStatement- Parameters:
queryID- The given query ID- Returns:
- An array of child query IDs
- Throws:
SQLException- If the query is running or the corresponding query is FAILED.
-
execute
public SFBaseResultSet execute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData) throws SQLException, SFException
Description copied from class:SFBaseStatementExecutes the given SQL string.- Specified by:
executein classSFBaseStatement- Parameters:
sql- The SQL string to execute, synchronously.parametersBinding- parameters to bindcaller- the JDBC interface method that called this method, if anyexecTimeData- OOB telemetry object to record timings- Returns:
- whether there is result set or not
- Throws:
SQLException- if failed to execute sqlSFException- exception raised from Snowflake components
-
execute
public SFBaseResultSet execute(String sql, boolean asyncExec, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData) throws SQLException, SFException
Execute sql- Parameters:
sql- sql statement.parametersBinding- parameters to bindcaller- the JDBC interface method that called this method, if any- Returns:
- whether there is result set or not
- Throws:
SQLException- if failed to execute sqlSFException- exception raised from Snowflake componentsSQLException- if SQL error occurs
-
close
public void close()
Description copied from class:SFBaseStatementCloses the statement. Open result sets are closed, connections are terminated, state is cleared, etc.- Specified by:
closein classSFBaseStatement
-
cancel
public void cancel() throws SFException, SQLExceptionDescription copied from class:SFBaseStatementAborts the statement.- Specified by:
cancelin classSFBaseStatement- 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:SFBaseStatementReturns the SFBaseSession associated with this SFBaseStatement.- Specified by:
getSFBaseSessionin classSFBaseStatement
-
getMoreResults
public boolean getMoreResults() throws SQLException- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws SQLExceptionDescription copied from class:SFBaseStatementSets the result set to the next one, if available.- Specified by:
getMoreResultsin classSFBaseStatement- 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:SFBaseStatementRetrieves 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:
getResultSetin classSFBaseStatement
-
hasChildren
public boolean hasChildren()
Description copied from class:SFBaseStatementIf this is a multi-statement, i.e., has child results.- Specified by:
hasChildrenin classSFBaseStatement
-
asyncExecute
public SFBaseResultSet asyncExecute(String sql, Map<String,ParameterBindingDTO> parametersBinding, SFBaseStatement.CallingMethod caller, ExecTimeTelemetryData execTimeData) throws SQLException, SFException
Description copied from class:SFBaseStatementExecute 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:
asyncExecutein classSFBaseStatement- Parameters:
sql- sql statement.parametersBinding- parameters to bindcaller- the JDBC interface method that called this method, if any- Returns:
- whether there is result set or not
- Throws:
SQLException- if failed to execute sqlSFException- exception raised from Snowflake components
-
-