Package com.databricks.jdbc.api.impl

## Class DatabricksStatement

- java.lang.Object
- - com.databricks.jdbc.api.impl.DatabricksStatement

All Implemented Interfaces:
  `IDatabricksStatement`, `IDatabricksStatementInternal`, `AutoCloseable`, `Statement`, `Wrapper`

Direct Known Subclasses:
  `DatabricksPreparedStatement`

    public class DatabricksStatement
    extends Object
    implements IDatabricksStatement, IDatabricksStatementInternal

### Field Summary

Fields
`protected DatabricksConnection` `connection`

### Fields inherited from interface java.sql.Statement

`CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO`

### Constructor Summary

Constructors
`DatabricksStatement​(DatabricksConnection connection)`
`DatabricksStatement​(DatabricksConnection connection, StatementId statementId)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addBatch​(String sql)`
`void` `allowInputStreamForVolumeOperation​(boolean allowInputStream)`
`void` `cancel()`
`void` `clearBatch()`
`void` `clearWarnings()`
`void` `close()`
`void` `close​(boolean removeFromSession)`
`void` `closeOnCompletion()`
`String` `enquoteIdentifier​(String identifier, boolean alwaysQuote)`
`String` `enquoteLiteral​(String val)`
`String` `enquoteNCharLiteral​(String val)`
`boolean` `execute​(String sql)`
`boolean` `execute​(String sql, int autoGeneratedKeys)`
`boolean` `execute​(String sql, int[] columnIndexes)`
`boolean` `execute​(String sql, String[] columnNames)`
`ResultSet` `executeAsync​(String sql)` Executes the given SQL command asynchronously and returns a lightweight result set handle.
`int[]` `executeBatch()`
`long[]` `executeLargeBatch()`
`long` `executeLargeUpdate​(String sql)`
`long` `executeLargeUpdate​(String sql, int autoGeneratedKeys)`
`long` `executeLargeUpdate​(String sql, int[] columnIndexes)`
`long` `executeLargeUpdate​(String sql, String[] columnNames)`
`ResultSet` `executeQuery​(String sql)`
`int` `executeUpdate​(String sql)`
`int` `executeUpdate​(String sql, int autoGeneratedKeys)`
`int` `executeUpdate​(String sql, int[] columnIndexes)`
`int` `executeUpdate​(String sql, String[] columnNames)`
`Connection` `getConnection()`
`ResultSet` `getExecutionResult()` Retrieves the result set for a previously executed statement.
`int` `getFetchDirection()`
`int` `getFetchSize()`
`ResultSet` `getGeneratedKeys()`
`org.apache.http.entity.InputStreamEntity` `getInputStreamForUCVolume()`
`long` `getLargeMaxRows()`
`long` `getLargeUpdateCount()`
`int` `getMaxFieldSize()`
`int` `getMaxRows()`
`boolean` `getMoreResults()`
`boolean` `getMoreResults​(int current)`
`int` `getQueryTimeout()`
`ResultSet` `getResultSet()`
`int` `getResultSetConcurrency()`
`int` `getResultSetHoldability()`
`int` `getResultSetType()`
`Statement` `getStatement()`
`StatementId` `getStatementId()`
`int` `getUpdateCount()`
`SQLWarning` `getWarnings()`
`void` `handleResultSetClose​(IDatabricksResultSet resultSet)`
`boolean` `isAllowedInputStreamForVolumeOperation()`
`boolean` `isClosed()`
`boolean` `isCloseOnCompletion()`
`boolean` `isPoolable()`
`boolean` `isSimpleIdentifier​(String identifier)`
`boolean` `isWrapperFor​(Class<?> iface)`
`void` `markAsClosed()` Marks the statement as closed without attempting to close it on the server or clean up local resources.
`void` `setCursorName​(String name)`
`void` `setEscapeProcessing​(boolean enable)`
`void` `setFetchDirection​(int direction)`
`void` `setFetchSize​(int rows)`
`void` `setInputStreamForUCVolume​(org.apache.http.entity.InputStreamEntity inputStream)`
`void` `setLargeMaxRows​(long max)`
`void` `setMaxFieldSize​(int max)`
`void` `setMaxRows​(int max)`
`void` `setPoolable​(boolean poolable)`
`void` `setQueryTimeout​(int seconds)`
`void` `setStatementId​(StatementId statementId)`
`String` `toString()`
`<T> T` `unwrap​(Class<T> iface)`

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

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

### Field Detail

#### connection

    protected final DatabricksConnection connection

### Constructor Detail

#### DatabricksStatement

    public DatabricksStatement​(DatabricksConnection connection)
                        throws DatabricksValidationException

Throws:
  `DatabricksValidationException`

#### DatabricksStatement

    public DatabricksStatement​(DatabricksConnection connection,
                               StatementId statementId)
                        throws DatabricksValidationException

Throws:
  `DatabricksValidationException`

### Method Detail

#### executeQuery

    public ResultSet executeQuery​(String sql)
                           throws SQLException

Specified by:
  `executeQuery` in interface `Statement`
Throws:
  `SQLException`

#### executeUpdate

    public int executeUpdate​(String sql)
                      throws SQLException

Specified by:
  `executeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeLargeUpdate

    public long executeLargeUpdate​(String sql)
                            throws SQLException

Specified by:
  `executeLargeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### close

    public void close()
               throws SQLException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Statement`
Throws:
  `SQLException`

#### close

    public void close​(boolean removeFromSession)
               throws DatabricksSQLException

Specified by:
  `close` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### getMaxFieldSize

    public int getMaxFieldSize()
                        throws SQLException

Specified by:
  `getMaxFieldSize` in interface `Statement`
Throws:
  `SQLException`

#### setMaxFieldSize

    public void setMaxFieldSize​(int max)
                         throws SQLException

Specified by:
  `setMaxFieldSize` in interface `Statement`
Throws:
  `SQLException`

#### getMaxRows

    public int getMaxRows()
                   throws DatabricksSQLException

Specified by:
  `getMaxRows` in interface `IDatabricksStatementInternal`
Specified by:
  `getMaxRows` in interface `Statement`
Throws:
  `DatabricksSQLException`

#### getLargeMaxRows

    public long getLargeMaxRows()
                         throws DatabricksSQLException

Specified by:
  `getLargeMaxRows` in interface `Statement`
Throws:
  `DatabricksSQLException`

#### setMaxRows

    public void setMaxRows​(int max)
                    throws SQLException

Specified by:
  `setMaxRows` in interface `Statement`
Throws:
  `SQLException`

#### setLargeMaxRows

    public void setLargeMaxRows​(long max)
                         throws SQLException

Specified by:
  `setLargeMaxRows` in interface `Statement`
Throws:
  `SQLException`

#### setEscapeProcessing

    public void setEscapeProcessing​(boolean enable)
                             throws SQLException

Specified by:
  `setEscapeProcessing` in interface `Statement`
Throws:
  `SQLException`

#### getQueryTimeout

    public int getQueryTimeout()
                        throws SQLException

Specified by:
  `getQueryTimeout` in interface `Statement`
Throws:
  `SQLException`

#### setQueryTimeout

    public void setQueryTimeout​(int seconds)
                         throws SQLException

Specified by:
  `setQueryTimeout` in interface `Statement`
Throws:
  `SQLException`

#### cancel

    public void cancel()
                throws SQLException

Specified by:
  `cancel` in interface `Statement`
Throws:
  `SQLException`

#### getWarnings

    public SQLWarning getWarnings()

Specified by:
  `getWarnings` in interface `Statement`

#### clearWarnings

    public void clearWarnings()

Specified by:
  `clearWarnings` in interface `Statement`

#### setCursorName

    public void setCursorName​(String name)
                       throws SQLException

Specified by:
  `setCursorName` in interface `Statement`
Throws:
  `SQLException`

#### execute

    public boolean execute​(String sql)
                    throws SQLException

Specified by:
  `execute` in interface `Statement`
Throws:
  `SQLException`

#### getResultSet

    public ResultSet getResultSet()
                           throws SQLException

Specified by:
  `getResultSet` in interface `Statement`
Throws:
  `SQLException`

#### getUpdateCount

    public int getUpdateCount()
                       throws SQLException

Specified by:
  `getUpdateCount` in interface `Statement`
Throws:
  `SQLException`

#### getLargeUpdateCount

    public long getLargeUpdateCount()
                             throws SQLException

Specified by:
  `getLargeUpdateCount` in interface `Statement`
Throws:
  `SQLException`

#### getMoreResults

    public boolean getMoreResults()
                           throws SQLException

Specified by:
  `getMoreResults` in interface `Statement`
Throws:
  `SQLException`

#### setFetchDirection

    public void setFetchDirection​(int direction)
                           throws SQLException

Specified by:
  `setFetchDirection` in interface `Statement`
Throws:
  `SQLException`

#### getFetchDirection

    public int getFetchDirection()
                          throws SQLException

Specified by:
  `getFetchDirection` in interface `Statement`
Throws:
  `SQLException`

#### setFetchSize

    public void setFetchSize​(int rows)

Specified by:
  `setFetchSize` in interface `Statement`

#### getFetchSize

    public int getFetchSize()

Specified by:
  `getFetchSize` in interface `Statement`

#### getResultSetConcurrency

    public int getResultSetConcurrency()
                                throws SQLException

Specified by:
  `getResultSetConcurrency` in interface `Statement`
Throws:
  `SQLException`

#### getResultSetType

    public int getResultSetType()
                         throws SQLException

Specified by:
  `getResultSetType` in interface `Statement`
Throws:
  `SQLException`

#### addBatch

    public void addBatch​(String sql)
                  throws SQLException

Specified by:
  `addBatch` in interface `Statement`
Throws:
  `SQLException`

#### clearBatch

    public void clearBatch()
                    throws SQLException

Specified by:
  `clearBatch` in interface `Statement`
Throws:
  `SQLException`

#### executeBatch

    public int[] executeBatch()
                       throws SQLException

Specified by:
  `executeBatch` in interface `Statement`
Throws:
  `SQLException`

#### executeLargeBatch

    public long[] executeLargeBatch()
                             throws SQLException

Specified by:
  `executeLargeBatch` in interface `Statement`
Throws:
  `SQLException`

#### getConnection

    public Connection getConnection()
                             throws SQLException

Specified by:
  `getConnection` in interface `Statement`
Throws:
  `SQLException`

#### getMoreResults

    public boolean getMoreResults​(int current)
                           throws SQLException

Specified by:
  `getMoreResults` in interface `Statement`
Throws:
  `SQLException`

#### getGeneratedKeys

    public ResultSet getGeneratedKeys()
                               throws SQLException

Specified by:
  `getGeneratedKeys` in interface `Statement`
Throws:
  `SQLException`

#### executeUpdate

    public int executeUpdate​(String sql,
                             int autoGeneratedKeys)
                      throws SQLException

Specified by:
  `executeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeLargeUpdate

    public long executeLargeUpdate​(String sql,
                                   int autoGeneratedKeys)
                            throws SQLException

Specified by:
  `executeLargeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeUpdate

    public int executeUpdate​(String sql,
                             int[] columnIndexes)
                      throws SQLException

Specified by:
  `executeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeLargeUpdate

    public long executeLargeUpdate​(String sql,
                                   int[] columnIndexes)
                            throws SQLException

Specified by:
  `executeLargeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeUpdate

    public int executeUpdate​(String sql,
                             String[] columnNames)
                      throws SQLException

Specified by:
  `executeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### executeLargeUpdate

    public long executeLargeUpdate​(String sql,
                                   String[] columnNames)
                            throws SQLException

Specified by:
  `executeLargeUpdate` in interface `Statement`
Throws:
  `SQLException`

#### execute

    public boolean execute​(String sql,
                           int autoGeneratedKeys)
                    throws SQLException

Specified by:
  `execute` in interface `Statement`
Throws:
  `SQLException`

#### execute

    public boolean execute​(String sql,
                           int[] columnIndexes)
                    throws SQLException

Specified by:
  `execute` in interface `Statement`
Throws:
  `SQLException`

#### execute

    public boolean execute​(String sql,
                           String[] columnNames)
                    throws SQLException

Specified by:
  `execute` in interface `Statement`
Throws:
  `SQLException`

#### getResultSetHoldability

    public int getResultSetHoldability()

Specified by:
  `getResultSetHoldability` in interface `Statement`

#### isClosed

    public boolean isClosed()
                     throws SQLException

Specified by:
  `isClosed` in interface `Statement`
Throws:
  `SQLException`

#### setPoolable

    public void setPoolable​(boolean poolable)
                     throws SQLException

Specified by:
  `setPoolable` in interface `Statement`
Throws:
  `SQLException`

#### isPoolable

    public boolean isPoolable()
                       throws SQLException

Specified by:
  `isPoolable` in interface `Statement`
Throws:
  `SQLException`

#### closeOnCompletion

    public void closeOnCompletion()
                           throws SQLException

Specified by:
  `closeOnCompletion` in interface `Statement`
Throws:
  `SQLException`

#### isCloseOnCompletion

    public boolean isCloseOnCompletion()
                                throws SQLException

Specified by:
  `isCloseOnCompletion` in interface `Statement`
Throws:
  `SQLException`

#### unwrap

    public <T> T unwrap​(Class<T> iface)
                 throws SQLException

Specified by:
  `unwrap` in interface `Wrapper`
Throws:
  `SQLException`

#### isWrapperFor

    public boolean isWrapperFor​(Class<?> iface)
                         throws SQLException

Specified by:
  `isWrapperFor` in interface `Wrapper`
Throws:
  `SQLException`

#### handleResultSetClose

    public void handleResultSetClose​(IDatabricksResultSet resultSet)
                              throws DatabricksSQLException

Specified by:
  `handleResultSetClose` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### setStatementId

    public void setStatementId​(StatementId statementId)

Specified by:
  `setStatementId` in interface `IDatabricksStatementInternal`

#### getStatementId

    public StatementId getStatementId()

Specified by:
  `getStatementId` in interface `IDatabricksStatementInternal`

#### getStatement

    public Statement getStatement()

Specified by:
  `getStatement` in interface `IDatabricksStatementInternal`

#### allowInputStreamForVolumeOperation

    public void allowInputStreamForVolumeOperation​(boolean allowInputStream)
                                            throws DatabricksSQLException

Specified by:
  `allowInputStreamForVolumeOperation` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### isAllowedInputStreamForVolumeOperation

    public boolean isAllowedInputStreamForVolumeOperation()
                                                   throws DatabricksSQLException

Specified by:
  `isAllowedInputStreamForVolumeOperation` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### setInputStreamForUCVolume

    public void setInputStreamForUCVolume​(org.apache.http.entity.InputStreamEntity inputStream)
                                   throws DatabricksSQLException

Specified by:
  `setInputStreamForUCVolume` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### getInputStreamForUCVolume

    public org.apache.http.entity.InputStreamEntity getInputStreamForUCVolume()
                                                                       throws DatabricksSQLException

Specified by:
  `getInputStreamForUCVolume` in interface `IDatabricksStatementInternal`
Throws:
  `DatabricksSQLException`

#### executeAsync

    public ResultSet executeAsync​(String sql)
                           throws SQLException

Description copied from interface: `IDatabricksStatement`
Executes the given SQL command asynchronously and returns a lightweight result set handle. This method initiates the execution but does not wait for it to complete, making it suitable for long-running queries. The actual results can be retrieved later using `IDatabricksStatement.getExecutionResult()`.

Specified by:
  `executeAsync` in interface `IDatabricksStatement`
Parameters:
  `sql` - The SQL command to be executed
Returns:
  A `ResultSet` handle that can be used to track and retrieve the results
Throws:
  `SQLException` - if a database access error occurs, this method is called on a closed statement, or the SQL command is not valid

#### getExecutionResult

    public ResultSet getExecutionResult()
                                 throws SQLException

Description copied from interface: `IDatabricksStatement`
Retrieves the result set for a previously executed statement. This method should be called after executing a statement using `IDatabricksStatement.executeAsync(String)` to get the actual results.

Specified by:
  `getExecutionResult` in interface `IDatabricksStatement`
Returns:
  A `ResultSet` containing the results of the statement execution in case of successful completion, else handle for the result status.
Throws:
  `SQLException` - if the statement was never executed, has been closed, or if a database access error occurs

#### enquoteLiteral

    public String enquoteLiteral​(String val)
                          throws SQLException

Specified by:
  `enquoteLiteral` in interface `Statement`
Throws:
  `SQLException`

#### enquoteIdentifier

    public String enquoteIdentifier​(String identifier,
                                    boolean alwaysQuote)
                             throws DatabricksSQLException

Specified by:
  `enquoteIdentifier` in interface `Statement`
Throws:
  `DatabricksSQLException`

#### enquoteNCharLiteral

    public String enquoteNCharLiteral​(String val)
                               throws SQLException

Specified by:
  `enquoteNCharLiteral` in interface `Statement`
Throws:
  `SQLException`

#### isSimpleIdentifier

    public boolean isSimpleIdentifier​(String identifier)
                               throws SQLException

Specified by:
  `isSimpleIdentifier` in interface `Statement`
Throws:
  `SQLException`

#### markAsClosed

    public void markAsClosed()

Marks the statement as closed without attempting to close it on the server or clean up local resources. This should be used when the server has already indicated the statement is closed.

This method sets the closed flag to prevent further operations, but defers resource cleanup (result set, executor) to the `close(boolean)` method. When `close()` is subsequently called, it will detect the statement is already closed and skip the server-side close operation while still cleaning up local resources.

See Also:
  `close(boolean)`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`