Class SFStatement

    • Constructor Detail

      • SFStatement

        public SFStatement​(SFSession session)
    • Method Detail

      • 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
      • 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:
        getChildQueryIds in class SFBaseStatement
        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.
      • 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
      • 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
      • 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