Package com.sas.rio

Class MVAStatement

java.lang.Object
com.sas.rio.MVAStatement
All Implemented Interfaces:
com.sas.rio.RIOStatementInterface, com.sas.sql.RIOStatement, AutoCloseable, Statement, Wrapper
Direct Known Subclasses:
MVAPreparedStatement

public class MVAStatement extends Object implements RIOStatementInterface

A Statement object is used for executing a static SQL statement and obtaining the results produced by it.

Only one ResultSet per Statement can be open at any point in time. Therefore, if the reading of one ResultSet is interleaved with the reading of another, each must have been generated by different Statements. All statement execute methods implicitly close a statment's current ResultSet if an open one exists.

See Also:
  • Connection.createStatement()
  • ResultSet
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected MVAResultSet
     
    protected boolean
     
    protected final List<String>
     
    protected final int
     
    protected int
     

    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
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBatch(String sql)
    protected void
    addBatch2(com.sas.rio.ParsedQuery _parsedQuery, String[] parameters)
     
    void
    protected void
     
    void
    void
    void
    void
     
    createDualResultSet(String libref, String tableName, String[] password, String options)
    Creates a MVADualResultSet for access to server side formatted data along with unformatted data.
    void
    createTable(String libref, String tableName, com.sas.rio.Column[] columnObject, String options)
    Deprecated.
    prefer use of create table by executeUpdate with SQL grammar.
    void
    deleteRioTable(String libref, String tableName)
     
    void
    deleteRioTable(String libref, String tableName, String tableType, String alterPassword)
     
    void
    deleteTable(String libref, String tableName)
    Deletes the table with the name specified in the tableName String.
    void
    deleteTable(String libref, String tableName, String tableType, String alterPassword)
    RIO Deletes the table for the specified tableType with the name specified in the tableName String.
    boolean
    execute(String sql)
    Execute a SQL statement that may return multiple results.
    boolean
    execute(String sql, int autoGeneratedKeys)
    Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
    boolean
    execute(String sql, int[] columnIndexes)
    Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
    boolean
    execute(String sql, String[] columnNames)
    Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
    protected boolean
    execute2(com.sas.rio.ParsedQuery pq, String[] parameters)
     
    int[]
    ResultSet
    executeQuery(String query)
    protected ResultSet
    executeQuery2(com.sas.rio.ParsedQuery pq, String[] parameters)
     
    int
    executeUpdate(String sql)
    Executes an SQL INSERT, UPDATE or DELETE statement.
    int
    executeUpdate(String sql, int autoGeneratedKeys)
    Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval.
    int
    executeUpdate(String sql, int[] columnIndexes)
    Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
    int
    executeUpdate(String sql, String[] columnNames)
    Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
    protected int
    executeUpdate2(com.sas.rio.ParsedQuery pq, String[] parameters)
     
    Connection
    ResultSet
    getDualRioTable(String libref, String tableName, String[] password, String options)
     
    int
    The IOM JDBC driver always returns ResultSet.FETCH_FORWARD for the fetch direction, as calls to setFetchDirection(int) are silently ignored.
    int
    ResultSet
    The MVAStatement implementation of getGeneratedKeys always returns an empty result set.
    int
    int
    boolean
    boolean
    getMoreResults(int current)
    Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.
    int
    The MVAStatement implementation of getQueryTimeout always returns 0.
    ResultSet
    int
    int
    int
    ResultSet
    getRioTable(String libref, String tableName)
     
    ResultSet
    getRioTable(String libref, String tableName, String tableType, String[] password, String options)
     
    ResultSet
    getTable(String libref, String tableName)
    RIO Gets an MVAResultSet object for the given table name.By default all the columns and all rows are selected.
    ResultSet
    getTable(String libref, String tableName, String tableType, String[] password, String options)
    RIO Gets an MVAResultSet object for the given table name.
    int
    SQLWarning
    boolean
    boolean
     
    boolean
    boolean
    isWrapperFor(Class<?> iface)
    void
    setCursorName(String name)
    The MVAStatement implementation of setCursorName has no effect.
    void
    setEscapeProcessing(boolean enable)
    void
    setFetchDirection(int direction)
    The IOM JDBC driver silently ignores the hint to set the fetch direction.
    void
    setFetchSize(int rows)
    void
    setMaxFieldSize(int max)
    void
    setMaxRows(int max)
    void
    setPoolable(boolean poolable)
    void
    setQueryTimeout(int seconds)
    The MVAStatement implementation of setQueryTimeout has no effect.
    <T> T
    unwrap(Class<T> iface)

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.sql.Statement

    enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, getLargeUpdateCount, isSimpleIdentifier, setLargeMaxRows
  • Field Details

    • m_sasifyTableNames

      protected final int m_sasifyTableNames
    • maxFieldSize

      protected int maxFieldSize
    • _currentResultSet

      protected MVAResultSet _currentResultSet
    • describe

      protected boolean describe
    • _closeOnCompletion

      protected boolean _closeOnCompletion
    • librefs

      protected final List<String> librefs
  • Method Details

    • executeQuery

      public ResultSet executeQuery(String query) throws SQLException
      Specified by:
      executeQuery in interface Statement
      Throws:
      SQLException
    • executeQuery2

      protected ResultSet executeQuery2(com.sas.rio.ParsedQuery pq, String[] parameters) throws SQLException, MVASQLException
      Throws:
      SQLException
      MVASQLException
    • executeUpdate

      public int executeUpdate(String sql) throws SQLException
      Executes an SQL INSERT, UPDATE or DELETE statement.
      Specified by:
      executeUpdate in interface Statement
      Parameters:
      sql - A SQL INSERT, UPDATE or DELETE statement.
      Returns:
      The row count for INSERT, UPDATE or DELETE.
      Throws:
      SQLException - This exception is thrown if an exception is detected.
    • executeUpdate2

      protected int executeUpdate2(com.sas.rio.ParsedQuery pq, String[] parameters) throws MVASQLException, SQLException
      Throws:
      MVASQLException
      SQLException
    • close

      public void close() throws SQLException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Statement
      Throws:
      SQLException
    • getMaxFieldSize

      public int getMaxFieldSize() throws SQLException
      Specified by:
      getMaxFieldSize in interface Statement
      Throws:
      SQLException
    • checkClosed

      protected void checkClosed() throws MVASQLException
      Throws:
      MVASQLException
    • setMaxFieldSize

      public void setMaxFieldSize(int max) throws SQLException
      Specified by:
      setMaxFieldSize in interface Statement
      Throws:
      SQLException
    • getMaxRows

      public int getMaxRows() throws SQLException
      Specified by:
      getMaxRows in interface Statement
      Throws:
      SQLException
    • setMaxRows

      public void setMaxRows(int max) throws SQLException
      Specified by:
      setMaxRows 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
      The MVAStatement implementation of getQueryTimeout always returns 0. Query timeout is not supported by the underlying database.

      Specified by:
      getQueryTimeout in interface Statement
      Throws:
      SQLException
    • setQueryTimeout

      public void setQueryTimeout(int seconds) throws SQLException
      The MVAStatement implementation of setQueryTimeout has no effect. Query timeout is not supported by the underlying database.

      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() throws SQLException
      Specified by:
      getWarnings in interface Statement
      Throws:
      SQLException
    • clearWarnings

      public void clearWarnings() throws SQLException
      Specified by:
      clearWarnings in interface Statement
      Throws:
      SQLException
    • setCursorName

      public void setCursorName(String name) throws SQLException
      The MVAStatement implementation of setCursorName has no effect. Cursors are not supported by the underlying database.

      Specified by:
      setCursorName in interface Statement
      Throws:
      SQLException
    • execute

      public boolean execute(String sql) throws SQLException
      Execute a SQL statement that may return multiple results. Under some (uncommon) situations a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this, unless you're executing a stored procedure that you know may return multiple results, or unless you're dynamically executing an unknown SQL string. The "execute", "getMoreResults", "getResultSet" and "getUpdateCount" methods let you navigate through multiple results. The "execute" method executes a SQL statement and indicates the form of the first result. You can then use getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).
      Specified by:
      execute in interface Statement
      Parameters:
      sql - An SQL statement
      Returns:
      True if the next result is a ResultSet. False if it is an update count or there are no more results
      Throws:
      SQLException - This exception is thrown if an MvaException is detected.
      See Also:
    • execute2

      protected boolean execute2(com.sas.rio.ParsedQuery pq, String[] parameters) throws SQLException, MVASQLException
      Throws:
      SQLException
      MVASQLException
    • 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
    • getMoreResults

      public boolean getMoreResults() throws SQLException
      Specified by:
      getMoreResults in interface Statement
      Throws:
      SQLException
    • setFetchDirection

      public void setFetchDirection(int direction) throws SQLException
      The IOM JDBC driver silently ignores the hint to set the fetch direction.

      Specified by:
      setFetchDirection in interface Statement
      Throws:
      SQLException
    • getFetchDirection

      public int getFetchDirection() throws SQLException
      The IOM JDBC driver always returns ResultSet.FETCH_FORWARD for the fetch direction, as calls to setFetchDirection(int) are silently ignored.

      Specified by:
      getFetchDirection in interface Statement
      Throws:
      SQLException
    • setFetchSize

      public void setFetchSize(int rows) throws SQLException
      Specified by:
      setFetchSize in interface Statement
      Throws:
      SQLException
    • getFetchSize

      public int getFetchSize() throws SQLException
      Specified by:
      getFetchSize in interface Statement
      Throws:
      SQLException
    • 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
    • addBatch2

      protected void addBatch2(com.sas.rio.ParsedQuery _parsedQuery, String[] parameters) throws SQLException
      Throws:
      SQLException
    • clearBatch

      public void clearBatch() throws SQLException
      Specified by:
      clearBatch in interface Statement
      Throws:
      SQLException
    • executeBatch

      public int[] executeBatch() throws SQLException, BatchUpdateException
      Specified by:
      executeBatch in interface Statement
      Throws:
      SQLException
      BatchUpdateException
    • getConnection

      public Connection getConnection() throws SQLException
      Specified by:
      getConnection in interface Statement
      Throws:
      SQLException
    • createTable

      @Deprecated public void createTable(String libref, String tableName, com.sas.rio.Column[] columnObject, String options) throws RIOException
      Deprecated.
      prefer use of create table by executeUpdate with SQL grammar.
      Creates a new table with the name specified in the tableName String. The columns to be created and their attributes are passed through the columnObject parameter. Any SAS options to be sent with the create table will be passed through the optionsObject parameter.

      Specified by:
      createTable in interface RIOStatementInterface
      Parameters:
      libref - The libref name. Cannot be NULL.
      tableName - The name of the table to be created. Table name cannot be NULL.
      columnObject - A Column Object array containing column names and attributes. Column object cannot be NULL.
      options - A String of applicable SAS DATASET options. May be NULL.
      Throws:
      RIOException - This exception may be thrown.
    • getTable

      public ResultSet getTable(String libref, String tableName) throws SQLException
      RIO Gets an MVAResultSet object for the given table name.By default all the columns and all rows are selected.
      Specified by:
      getTable in interface RIOStatementInterface
      Parameters:
      libref - The libref name. Cannot be NULL.
      tableName - The name of the table. Table name cannot be NULL. By default, the driver looks for a dataset to open, if one doesn't exist it looks for a view to open. If both exist, it opens a dataset.
      Returns:
      An MVAResultSet object. All columns and all rows are selected.
      Throws:
      RIOException - This exception may be thrown.
      SQLException
    • getTable

      public ResultSet getTable(String libref, String tableName, String tableType, String[] password, String options) throws SQLException
      RIO Gets an MVAResultSet object for the given table name.
      Specified by:
      getTable in interface RIOStatementInterface
      Parameters:
      libref - The libref name. Cannot be NULL.
      tableName - The name of the table to be opened.
      tableType - The type of the table to be opened.It could be "DATA" or "VIEW". If NULL, the driver looks for a dataset to open, if one doesn't exist it looks for a view to open. If both exist, it opens a dataset. This parameter is currently being ignored and defaulted to NULL.
      password - A String array of 3 elements specifying READ, WRITE and ALTER passwords if any. This parameter can be NULL. The first element is the READ password, the second the WRITE password and the third the ALTER password.
      options - A String whose contents can be any SAS dataset options appropriate to the underlying engine and library. This includes the WHERE clause. options can be NULL.
      Returns:
      An MVAResultSet object. The ResultSet could be a subset of the actual set of columns and rows.
      Throws:
      RIOException - This exception may be thrown.
      SQLException
    • deleteTable

      public void deleteTable(String libref, String tableName) throws RIOException
      Deletes the table with the name specified in the tableName String.
      Specified by:
      deleteTable in interface RIOStatementInterface
      Parameters:
      libref - The libref name. Cannot be NULL.
      tableName - The name of the table to be deleted. By default, the tableName dataset will be deleted.
      Throws:
      RIOException - This exception may be thrown.
    • deleteTable

      public void deleteTable(String libref, String tableName, String tableType, String alterPassword) throws RIOException
      RIO Deletes the table for the specified tableType with the name specified in the tableName String.
      Specified by:
      deleteTable in interface RIOStatementInterface
      Parameters:
      libref - The libref name. Cannot be NULL.
      tableName - The name of the table to be deleted.
      tableType - The type of the table. It could be "DATA" or "VIEW" or any table type available in the database. If NULL, the tableName dataset will be deleted.
      alterPassword - The alter password.
      Throws:
      RIOException - This exception may be thrown.
    • executeUpdate

      public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
      Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval. The driver will ignore this signal if the SQL statement is not an INSERT statement. Method not implemented.
      Specified by:
      executeUpdate in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • executeUpdate

      public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
      Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The driver will ignore the array if the SQL statement is not an INSERT statement. Method not implemented.
      Specified by:
      executeUpdate in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • executeUpdate

      public int executeUpdate(String sql, String[] columnNames) throws SQLException
      Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The driver will ignore the array if the SQL statement is not an INSERT statement. Method not implemented.
      Specified by:
      executeUpdate in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • execute

      public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
      Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval. Method not implemented.
      Specified by:
      execute in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • execute

      public boolean execute(String sql, int[] columnIndexes) throws SQLException
      Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The driver will ignore the array if the SQL statement is not an INSERT statement. Method not implemented.
      Specified by:
      execute in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • execute

      public boolean execute(String sql, String[] columnNames) throws SQLException
      Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The driver will ignore the array if the SQL statement is not an INSERT statement. Method not implemented.
      Specified by:
      execute in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • getGeneratedKeys

      public ResultSet getGeneratedKeys() throws SQLException
      The MVAStatement implementation of getGeneratedKeys always returns an empty result set. The underlying database does not support key generation.

      Specified by:
      getGeneratedKeys in interface Statement
      Throws:
      SQLException
    • getMoreResults

      public boolean getMoreResults(int current) throws SQLException
      Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object. Method not implemented.
      Specified by:
      getMoreResults in interface Statement
      Throws:
      SQLException - Always thrown, to indicate that this method is not implemented.
    • getResultSetHoldability

      public int getResultSetHoldability() throws SQLException
      Specified by:
      getResultSetHoldability in interface Statement
      Throws:
      SQLException
    • 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
    • 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
    • createDualResultSet

      public MVADualResultSet createDualResultSet(String libref, String tableName, String[] password, String options) throws SQLException
      Creates a MVADualResultSet for access to server side formatted data along with unformatted data.
      Specified by:
      createDualResultSet in interface RIOStatementInterface
      Parameters:
      libref - the containing libref
      tableName - the table to open
      password - password, or null if none required
      options - data set options, or null if none provided
      Returns:
      an instance of an MVADualResultSet
      Throws:
      SQLException
    • getRioTable

      public ResultSet getRioTable(String libref, String tableName) throws SQLException
      Specified by:
      getRioTable in interface com.sas.sql.RIOStatement
      Throws:
      SQLException
    • getRioTable

      public ResultSet getRioTable(String libref, String tableName, String tableType, String[] password, String options) throws SQLException
      Specified by:
      getRioTable in interface com.sas.sql.RIOStatement
      Throws:
      SQLException
    • getDualRioTable

      public ResultSet getDualRioTable(String libref, String tableName, String[] password, String options) throws SQLException
      Specified by:
      getDualRioTable in interface com.sas.sql.RIOStatement
      Throws:
      SQLException
    • deleteRioTable

      public void deleteRioTable(String libref, String tableName) throws SQLException
      Specified by:
      deleteRioTable in interface com.sas.sql.RIOStatement
      Throws:
      SQLException
    • deleteRioTable

      public void deleteRioTable(String libref, String tableName, String tableType, String alterPassword) throws SQLException
      Specified by:
      deleteRioTable in interface com.sas.sql.RIOStatement
      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