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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected MVAResultSetprotected booleanprotected final List<String> protected final intprotected intFields 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 TypeMethodDescriptionvoidaddBatch(String sql) protected voidaddBatch2(com.sas.rio.ParsedQuery _parsedQuery, String[] parameters) voidcancel()protected voidvoidvoidvoidclose()voidcreateDualResultSet(String libref, String tableName, String[] password, String options) Creates aMVADualResultSetfor access to server side formatted data along with unformatted data.voidcreateTable(String libref, String tableName, com.sas.rio.Column[] columnObject, String options) Deprecated.prefer use of create table by executeUpdate with SQL grammar.voiddeleteRioTable(String libref, String tableName) voiddeleteRioTable(String libref, String tableName, String tableType, String alterPassword) voiddeleteTable(String libref, String tableName) Deletes the table with the name specified in the tableName String.voiddeleteTable(String libref, String tableName, String tableType, String alterPassword) RIO Deletes the table for the specified tableType with the name specified in the tableName String.booleanexecute(String sql) Execute a SQL statement that may return multiple results.booleanexecute(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.booleanexecute(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.booleanexecute(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 booleanexecute2(com.sas.rio.ParsedQuery pq, String[] parameters) int[]ResultSetexecuteQuery(String query) protected ResultSetexecuteQuery2(com.sas.rio.ParsedQuery pq, String[] parameters) intexecuteUpdate(String sql) Executes an SQL INSERT, UPDATE or DELETE statement.intexecuteUpdate(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.intexecuteUpdate(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.intexecuteUpdate(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 intexecuteUpdate2(com.sas.rio.ParsedQuery pq, String[] parameters) ConnectionResultSetgetDualRioTable(String libref, String tableName, String[] password, String options) intThe IOM JDBC driver always returnsResultSet.FETCH_FORWARDfor the fetch direction, as calls tosetFetchDirection(int)are silently ignored.intResultSetTheMVAStatementimplementation ofgetGeneratedKeysalways returns an empty result set.intintbooleanbooleangetMoreResults(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.intTheMVAStatementimplementation ofgetQueryTimeoutalways returns 0.ResultSetintintintResultSetgetRioTable(String libref, String tableName) ResultSetgetRioTable(String libref, String tableName, String tableType, String[] password, String options) ResultSetgetTable(String libref, String tableName) RIO Gets an MVAResultSet object for the given table name.By default all the columns and all rows are selected.ResultSetgetTable(String libref, String tableName, String tableType, String[] password, String options) RIO Gets an MVAResultSet object for the given table name.intSQLWarningbooleanisClosed()booleanbooleanbooleanisWrapperFor(Class<?> iface) voidsetCursorName(String name) TheMVAStatementimplementation ofsetCursorNamehas no effect.voidsetEscapeProcessing(boolean enable) voidsetFetchDirection(int direction) The IOM JDBC driver silently ignores the hint to set the fetch direction.voidsetFetchSize(int rows) voidsetMaxFieldSize(int max) voidsetMaxRows(int max) voidsetPoolable(boolean poolable) voidsetQueryTimeout(int seconds) TheMVAStatementimplementation ofsetQueryTimeouthas no effect.<T> Tunwrap(Class<T> iface) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-
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:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeQuery2
protected ResultSet executeQuery2(com.sas.rio.ParsedQuery pq, String[] parameters) throws SQLException, MVASQLException - Throws:
SQLExceptionMVASQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException Executes an SQL INSERT, UPDATE or DELETE statement.- Specified by:
executeUpdatein interfaceStatement- 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:
MVASQLExceptionSQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException
-
getMaxFieldSize
public int getMaxFieldSize() throws SQLException- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
checkClosed
- Throws:
MVASQLException
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws SQLException - Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
public int getMaxRows() throws SQLException- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
setMaxRows
public void setMaxRows(int max) throws SQLException - Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException - Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLException
-
getQueryTimeout
public int getQueryTimeout() throws SQLExceptionTheMVAStatementimplementation ofgetQueryTimeoutalways returns 0. Query timeout is not supported by the underlying database.- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws SQLException TheMVAStatementimplementation ofsetQueryTimeouthas no effect. Query timeout is not supported by the underlying database.- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLException
-
cancel
public void cancel() throws SQLException- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException- Specified by:
getWarningsin interfaceStatement- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException
-
setCursorName
public void setCursorName(String name) throws SQLException TheMVAStatementimplementation ofsetCursorNamehas no effect. Cursors are not supported by the underlying database.- Specified by:
setCursorNamein interfaceStatement- 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:
executein interfaceStatement- 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:
SQLExceptionMVASQLException
-
getResultSet
public ResultSet getResultSet() throws SQLException- Specified by:
getResultSetin interfaceStatement- Throws:
SQLException
-
getUpdateCount
public int getUpdateCount() throws SQLException- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults() throws SQLException- Specified by:
getMoreResultsin interfaceStatement- 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:
setFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchDirection
public int getFetchDirection() throws SQLExceptionThe IOM JDBC driver always returnsResultSet.FETCH_FORWARDfor the fetch direction, as calls tosetFetchDirection(int)are silently ignored.- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
setFetchSize
public void setFetchSize(int rows) throws SQLException - Specified by:
setFetchSizein interfaceStatement- Throws:
SQLException
-
getFetchSize
public int getFetchSize() throws SQLException- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws SQLException- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
getResultSetType
public int getResultSetType() throws SQLException- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLException
-
addBatch
public void addBatch(String sql) throws SQLException - Specified by:
addBatchin interfaceStatement- 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:
clearBatchin interfaceStatement- Throws:
SQLException
-
executeBatch
public int[] executeBatch() throws SQLException, BatchUpdateException- Specified by:
executeBatchin interfaceStatement- Throws:
SQLExceptionBatchUpdateException
-
getConnection
public Connection getConnection() throws SQLException- Specified by:
getConnectionin interfaceStatement- 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:
createTablein interfaceRIOStatementInterface- 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:
getTablein interfaceRIOStatementInterface- 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:
getTablein interfaceRIOStatementInterface- 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
Deletes the table with the name specified in the tableName String.- Specified by:
deleteTablein interfaceRIOStatementInterface- 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:
deleteTablein interfaceRIOStatementInterface- 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:
executeUpdatein interfaceStatement- 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:
executeUpdatein interfaceStatement- 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:
executeUpdatein interfaceStatement- 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:
executein interfaceStatement- 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:
executein interfaceStatement- 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:
executein interfaceStatement- Throws:
SQLException- Always thrown, to indicate that this method is not implemented.
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLExceptionTheMVAStatementimplementation ofgetGeneratedKeysalways returns an empty result set. The underlying database does not support key generation.- Specified by:
getGeneratedKeysin interfaceStatement- 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:
getMoreResultsin interfaceStatement- Throws:
SQLException- Always thrown, to indicate that this method is not implemented.
-
getResultSetHoldability
public int getResultSetHoldability() throws SQLException- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException- Specified by:
isClosedin interfaceStatement- Throws:
SQLException
-
setPoolable
public void setPoolable(boolean poolable) throws SQLException - Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
isPoolable
public boolean isPoolable() throws SQLException- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException - Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException - Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
createDualResultSet
public MVADualResultSet createDualResultSet(String libref, String tableName, String[] password, String options) throws SQLException Creates aMVADualResultSetfor access to server side formatted data along with unformatted data.- Specified by:
createDualResultSetin interfaceRIOStatementInterface- Parameters:
libref- the containing libreftableName- the table to openpassword- password, ornullif none requiredoptions- data set options, ornullif none provided- Returns:
- an instance of an MVADualResultSet
- Throws:
SQLException
-
getRioTable
public ResultSet getRioTable(String libref, String tableName) throws SQLException - Specified by:
getRioTablein interfacecom.sas.sql.RIOStatement- Throws:
SQLException
-
getRioTable
public ResultSet getRioTable(String libref, String tableName, String tableType, String[] password, String options) throws SQLException - Specified by:
getRioTablein interfacecom.sas.sql.RIOStatement- Throws:
SQLException
-
getDualRioTable
public ResultSet getDualRioTable(String libref, String tableName, String[] password, String options) throws SQLException - Specified by:
getDualRioTablein interfacecom.sas.sql.RIOStatement- Throws:
SQLException
-
deleteRioTable
public void deleteRioTable(String libref, String tableName) throws SQLException - Specified by:
deleteRioTablein interfacecom.sas.sql.RIOStatement- Throws:
SQLException
-
deleteRioTable
public void deleteRioTable(String libref, String tableName, String tableType, String alterPassword) throws SQLException - Specified by:
deleteRioTablein interfacecom.sas.sql.RIOStatement- Throws:
SQLException
-
closeOnCompletion
public void closeOnCompletion() throws SQLException- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws SQLException- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-