com.sas.rio
Class MVAStatement

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

public class MVAStatement
implements com.sas.rio.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
protected  MVAResultSet _currentResultSet
           
protected  boolean describe
           
protected  java.util.List<java.lang.String> librefs
           
protected  int m_sasifyTableNames
           
protected  int maxFieldSize
           
 
Method Summary
 void addBatch(java.lang.String sql)
          
protected  void addBatch2(com.sas.rio.ParsedQuery _parsedQuery, java.lang.String[] parameters)
           
 void cancel()
          
protected  void checkClosed()
           
 void clearBatch()
          
 void clearWarnings()
          
 void close()
          
 MVADualResultSet createDualResultSet(java.lang.String libref, java.lang.String tableName, java.lang.String[] password, java.lang.String options)
          Creates a MVADualResultSet for access to server side formatted data along with unformatted data.
 void createTable(java.lang.String libref, java.lang.String tableName, com.sas.rio.Column[] columnObject, java.lang.String options)
          Deprecated. prefer use of create table by executeUpdate with SQL grammar.
 void deleteRioTable(java.lang.String libref, java.lang.String tableName)
           
 void deleteRioTable(java.lang.String libref, java.lang.String tableName, java.lang.String tableType, java.lang.String alterPassword)
           
 void deleteTable(java.lang.String libref, java.lang.String tableName)
          Deletes the table with the name specified in the tableName String.
 void deleteTable(java.lang.String libref, java.lang.String tableName, java.lang.String tableType, java.lang.String alterPassword)
          RIO Deletes the table for the specified tableType with the name specified in the tableName String.
 boolean execute(java.lang.String sql)
          Execute a SQL statement that may return multiple results.
 boolean execute(java.lang.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(java.lang.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(java.lang.String sql, java.lang.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, java.lang.String[] parameters)
           
 int[] executeBatch()
          
 java.sql.ResultSet executeQuery(java.lang.String query)
          
protected  java.sql.ResultSet executeQuery2(com.sas.rio.ParsedQuery pq, java.lang.String[] parameters)
           
 int executeUpdate(java.lang.String sql)
          Executes an SQL INSERT, UPDATE or DELETE statement.
 int executeUpdate(java.lang.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(java.lang.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(java.lang.String sql, java.lang.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, java.lang.String[] parameters)
           
 java.sql.Connection getConnection()
          
 java.sql.ResultSet getDualRioTable(java.lang.String libref, java.lang.String tableName, java.lang.String[] password, java.lang.String options)
           
 int getFetchDirection()
          The IOM JDBC driver always returns ResultSet.FETCH_FORWARD for the fetch direction, as calls to setFetchDirection(int) are silently ignored.
 int getFetchSize()
          
 java.sql.ResultSet getGeneratedKeys()
          The MVAStatement implementation of getGeneratedKeys always returns an empty result set.
 int getMaxFieldSize()
          
 int getMaxRows()
          
 boolean getMoreResults()
          
 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 getQueryTimeout()
          The MVAStatement implementation of getQueryTimeout always returns 0.
 java.sql.ResultSet getResultSet()
          
 int getResultSetConcurrency()
          
 int getResultSetHoldability()
          
 int getResultSetType()
          
 java.sql.ResultSet getRioTable(java.lang.String libref, java.lang.String tableName)
           
 java.sql.ResultSet getRioTable(java.lang.String libref, java.lang.String tableName, java.lang.String tableType, java.lang.String[] password, java.lang.String options)
           
 java.sql.ResultSet getTable(java.lang.String libref, java.lang.String tableName)
          RIO Gets an MVAResultSet object for the given table name.By default all the columns and all rows are selected.
 java.sql.ResultSet getTable(java.lang.String libref, java.lang.String tableName, java.lang.String tableType, java.lang.String[] password, java.lang.String options)
          RIO Gets an MVAResultSet object for the given table name.
 int getUpdateCount()
          
 java.sql.SQLWarning getWarnings()
          
 boolean isClosed()
          
 boolean isPoolable()
          
 boolean isWrapperFor(java.lang.Class<?> iface)
          
 void setCursorName(java.lang.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(java.lang.Class<T> iface)
          
 

Field Detail

m_sasifyTableNames

protected final int m_sasifyTableNames

maxFieldSize

protected int maxFieldSize

_currentResultSet

protected MVAResultSet _currentResultSet

describe

protected boolean describe

librefs

protected final java.util.List<java.lang.String> librefs
Method Detail

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String query)
                                throws java.sql.SQLException

Specified by:
executeQuery in interface java.sql.Statement
Throws:
java.sql.SQLException

executeQuery2

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

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Executes an SQL INSERT, UPDATE or DELETE statement.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - A SQL INSERT, UPDATE or DELETE statement.
Returns:
The row count for INSERT, UPDATE or DELETE.
Throws:
java.sql.SQLException - This exception is thrown if an exception is detected.

executeUpdate2

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

close

public void close()
           throws java.sql.SQLException

Specified by:
close in interface java.sql.Statement
Throws:
java.sql.SQLException

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException

Specified by:
getMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException

checkClosed

protected void checkClosed()
                    throws MVASQLException
Throws:
MVASQLException

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException

Specified by:
setMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException

Specified by:
getMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException

Specified by:
setMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException

Specified by:
setEscapeProcessing in interface java.sql.Statement
Throws:
java.sql.SQLException

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
The MVAStatement implementation of getQueryTimeout always returns 0. Query timeout is not supported by the underlying database.

Specified by:
getQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException

setQueryTimeout

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

Specified by:
setQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException

cancel

public void cancel()
            throws java.sql.SQLException

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException

Specified by:
getWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException

setCursorName

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

Specified by:
setCursorName in interface java.sql.Statement
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql)
                throws java.sql.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 java.sql.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:
java.sql.SQLException - This exception is thrown if an MvaException is detected.
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

execute2

protected boolean execute2(com.sas.rio.ParsedQuery pq,
                           java.lang.String[] parameters)
                    throws java.sql.SQLException,
                           MVASQLException
Throws:
java.sql.SQLException
MVASQLException

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException

Specified by:
getResultSet in interface java.sql.Statement
Throws:
java.sql.SQLException

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException

Specified by:
getUpdateCount in interface java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException

Specified by:
getMoreResults in interface java.sql.Statement
Throws:
java.sql.SQLException

setFetchDirection

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

Specified by:
setFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException

getFetchDirection

public int getFetchDirection()
                      throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException

Specified by:
setFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException

Specified by:
getFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException

Specified by:
getResultSetType in interface java.sql.Statement
Throws:
java.sql.SQLException

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException

Specified by:
addBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

addBatch2

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

clearBatch

public void clearBatch()
                throws java.sql.SQLException

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException,
                          java.sql.BatchUpdateException

Specified by:
executeBatch in interface java.sql.Statement
Throws:
java.sql.SQLException
java.sql.BatchUpdateException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

Specified by:
getConnection in interface java.sql.Statement
Throws:
java.sql.SQLException

createTable

@Deprecated
public void createTable(java.lang.String libref,
                                   java.lang.String tableName,
                                   com.sas.rio.Column[] columnObject,
                                   java.lang.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 com.sas.rio.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 java.sql.ResultSet getTable(java.lang.String libref,
                                   java.lang.String tableName)
                            throws java.sql.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 com.sas.rio.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.
java.sql.SQLException

getTable

public java.sql.ResultSet getTable(java.lang.String libref,
                                   java.lang.String tableName,
                                   java.lang.String tableType,
                                   java.lang.String[] password,
                                   java.lang.String options)
                            throws java.sql.SQLException
RIO Gets an MVAResultSet object for the given table name.

Specified by:
getTable in interface com.sas.rio.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.
java.sql.SQLException

deleteTable

public void deleteTable(java.lang.String libref,
                        java.lang.String tableName)
                 throws RIOException
Deletes the table with the name specified in the tableName String.

Specified by:
deleteTable in interface com.sas.rio.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(java.lang.String libref,
                        java.lang.String tableName,
                        java.lang.String tableType,
                        java.lang.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 com.sas.rio.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(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.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 java.sql.Statement
Throws:
java.sql.SQLException - Always thrown, to indicate that this method is not implemented.

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException

Specified by:
getResultSetHoldability in interface java.sql.Statement
Throws:
java.sql.SQLException

isClosed

public boolean isClosed()
                 throws java.sql.SQLException

Specified by:
isClosed in interface java.sql.Statement
Throws:
java.sql.SQLException

setPoolable

public void setPoolable(boolean poolable)
                 throws java.sql.SQLException

Specified by:
setPoolable in interface java.sql.Statement
Throws:
java.sql.SQLException

isPoolable

public boolean isPoolable()
                   throws java.sql.SQLException

Specified by:
isPoolable in interface java.sql.Statement
Throws:
java.sql.SQLException

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException

Specified by:
unwrap in interface java.sql.Wrapper
Throws:
java.sql.SQLException

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException

Specified by:
isWrapperFor in interface java.sql.Wrapper
Throws:
java.sql.SQLException

createDualResultSet

public MVADualResultSet createDualResultSet(java.lang.String libref,
                                            java.lang.String tableName,
                                            java.lang.String[] password,
                                            java.lang.String options)
                                     throws java.sql.SQLException
Creates a MVADualResultSet for access to server side formatted data along with unformatted data.

Specified by:
createDualResultSet in interface com.sas.rio.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:
java.sql.SQLException

getRioTable

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

getRioTable

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

getDualRioTable

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

deleteRioTable

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

deleteRioTable

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



Copyright © 2009 SAS Institute Inc. All Rights Reserved.