com.sas.net.sharenet
Class ShareNetStatement

com.sas.net.sharenet.ShareNetStatement
All Implemented Interfaces:
java.sql.Statement, java.sql.Wrapper
Direct Known Subclasses:
ShareNetPreparedStatement

public class ShareNetStatement
implements java.sql.Statement

ShareNetStatement implements java.sql.Statement


Field Summary
protected  ShareNetConnection connection
           
protected  boolean describe
           
protected  int fetchSize
           
protected  int maxFieldSize
           
protected static java.lang.String[] months
           
protected  com.sas.net.sharenet.Tcpmsg msg
           
protected  ShareNetResultSet snresultset
           
 
Method Summary
 void addBatch(java.lang.String sql)
          JDBC 2.0 Adds a SQL command to the current batch of commmands for the statement.
 void addWarning(java.sql.SQLWarning warning)
          Adds a warning to this Statement.
 void cancel()
          Cancels a query or execute statement.
 void clearBatch()
          JDBC 2.0 Clears the set of commands in the current batch.
 void clearWarnings()
          Clears the warnings for this Statement.
 void close()
          Closes the ShareNetStatement object.
protected  void describe()
          Open up a new query (select statement).
protected  void destroy()
          Destroy a query object.
 boolean execute(java.lang.String sql)
          Executes an SQL statement and indicates the form of the first result.
 boolean execute(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.
 boolean execute(java.lang.String sql, int[] columnIndexes)
          Executes the given SQL statement, which may return multiple results, 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, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
 int[] executeBatch()
          JDBC 2.0 Submits a batch of commands to the database for execution.
 java.sql.ResultSet executeQuery(java.lang.String query)
          Executes an SQL statement that returns a single ResultSet.
 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 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.
 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.
 java.lang.String fieldFormat(int i)
          Find the type of all the fields in the query.
 java.lang.String[] fieldNames()
          Find the names of all the fields in the query.
 int fieldType(int i)
          Find the type of all the fields in the query.
protected  void finalize()
          Protected method which cleans up state associated with this object.
protected  int findFirstString(java.lang.String stmt, java.lang.String token, int offset)
           
protected  com.sas.net.sharenet.Xhrspa3 getAns()
          Gets the state of the query.
 java.sql.Connection getConnection()
          JDBC 2.0 Gets the Connection that produced this Statement.
 int getFetchDirection()
          JDBC 2.0 Gets the fetch direction for the result set created by this statement.
 int getFetchSize()
          JDBC 2.0 Gets the number of rows to be fetched.
 java.sql.ResultSet getGeneratedKeys()
          Retrieves any auto-generated keys created as a result of executing this Statement object.
 int getMaxFieldSize()
          Indicates the maximum number of bytes that can be returned for a column.
 int getMaxRows()
          Indicates the maximum number of rows that can be returned in a ResultSet.
 boolean getMoreResults()
          Moves to a Statement's next result.
 boolean getMoreResults(int current)
          The method is not implemented at this time.
 int getQueryTimeout()
          Indicates the number of seconds the query waits before it times out.
 java.sql.ResultSet getResultSet()
          Gets the current ResultSet.
 int getResultSetConcurrency()
          JDBC 2.0 Gets the result set concurrency type CONCUR_READ_ONLY as the resultset is a READ ONLY resultset.
 int getResultSetHoldability()
          Retrieves the result set holdability for ResultSet objects generated by this Statement object.
 int getResultSetType()
          JDBC 2.0 Gets the result set type TYPE_FORWARD_ONLY as scrolling is not supported.
 int getUpdateCount()
          Returns the current result, which should be an integer value.
protected  com.sas.net.sharenet.SqlFieldArray getVars()
          Gets the state of the query.
 java.sql.SQLWarning getWarnings()
          Gets the warnings for this statement.
protected  boolean isDescribe()
           
 int numFields()
          Return the number of fields in the query.
protected  void prepare(java.lang.String statement)
          Open up a new query (select statement).
protected  void prepareDescribe(java.lang.String statement)
          Open up a new query (select statement).
 void setCursorName(java.lang.String name)
          Sets the cursor name.
protected  void setDescribe(boolean describe)
           
 void setEscapeProcessing(boolean enable)
          Sets escape processing.
 void setFetchDirection(int direction)
          JDBC 2.0 Gives a hint as to the direction in which the rows in the result set created by this statement will be processed.
 void setFetchSize(int rows)
          JDBC 2.0 Sets the number of rows to be fetched.
 void setMaxFieldSize(int max)
          Sets the limit for the number of bytes that can be returned for a column.
 void setMaxRows(int max)
          Sets the limit for the maximum number of rows that any ResultSet can contain to the given number.
 void setQueryTimeout(int seconds)
          Sets the query timeout limit.
protected  void setVars(com.sas.net.sharenet.SqlFieldArray vars)
          Gets the state of the query.
 

Field Detail

months

protected static java.lang.String[] months

fetchSize

protected int fetchSize

msg

protected com.sas.net.sharenet.Tcpmsg msg

maxFieldSize

protected int maxFieldSize

snresultset

protected ShareNetResultSet snresultset

connection

protected ShareNetConnection connection

describe

protected boolean describe
Method Detail

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String query)
                                throws java.sql.SQLException
Executes an SQL statement that returns a single ResultSet.

Specified by:
executeQuery in interface java.sql.Statement
Parameters:
query - Typically this is a static SQL SELECT statement.
Returns:
The ShareNetResultSet object which contains the data produced by execution of the SQL statement.
Throws:
java.sql.SQLException - This exception is thrown if any ShareNetExceptions are detected.

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 - An SQL INSERT, UPDATE or DELETE statement.
Returns:
The row count for either INSERT, UPDATE or DELETE.
Throws:
java.sql.SQLException - This exception is thrown if any ShareNetExceptions are detected.

close

public void close()
Closes the ShareNetStatement object.

Specified by:
close in interface java.sql.Statement

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException
Indicates the maximum number of bytes that can be returned for a column.

Specified by:
getMaxFieldSize in interface java.sql.Statement
Returns:
The limit on the number of bytes that can be returned for a column. The default limit is 200.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
Sets the limit for the number of bytes that can be returned for a column.

Specified by:
setMaxFieldSize in interface java.sql.Statement
Parameters:
max - The limit on the number of bytes that can be returned for a column.
Throws:
java.sql.SQLException - This exception is thrown if the value of max is less than 0.

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
Indicates the maximum number of rows that can be returned in a ResultSet. If the limit is exceeded, the excess rows are silently dropped.

Specified by:
getMaxRows in interface java.sql.Statement
Returns:
The limit on the number of rows that can be returned in a ResultSet. zero means unlimited.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException
Sets the limit for the maximum number of rows that any ResultSet can contain to the given number. If the limit is exceeded, the excess rows are silently dropped.

Specified by:
setMaxRows in interface java.sql.Statement
Parameters:
max - The limit on the number rows that can be returned in a ResultSet. zero means unlimited.
Throws:
java.sql.SQLException - This exception is thrown if the value of max is less than 0.

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
Sets escape processing. SAS software does not allow escape processing.

Specified by:
setEscapeProcessing in interface java.sql.Statement
Parameters:
enable - The value for this parameter must be False.
Throws:
java.sql.SQLException - This exception is thrown if value of enable is True.

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
Indicates the number of seconds the query waits before it times out.

Specified by:
getQueryTimeout in interface java.sql.Statement
Returns:
0. Timeout is currently not supported.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
Sets the query timeout limit.

Specified by:
setQueryTimeout in interface java.sql.Statement
Parameters:
seconds - The value of this parameter must be 0. Timeout is currently not supported.
Throws:
java.sql.SQLException - This exception is thrown if value of seconds is not equal to 0.

cancel

public void cancel()
            throws java.sql.SQLException
Cancels a query or execute statement.

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException - This exception may be thrown.

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Gets the warnings for this statement.

Specified by:
getWarnings in interface java.sql.Statement
Returns:
An SQLWarning.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Clears the warnings for this Statement.

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Sets the cursor name. Cursors are not supported by SAS software so the cursor name will be ignored.

Specified by:
setCursorName in interface java.sql.Statement
Parameters:
name - The new cursor name.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Executes an SQL statement and indicates the form of the first result. You can then use getResultSet() or getUpdateCount() to retrieve the result.

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - An SQL statement.
Returns:
True if the result is a ResultSet; False if it is an integer
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException
Gets the current ResultSet. This method should only be called once per ResultSet.

Specified by:
getResultSet in interface java.sql.Statement
Returns:
The current result as a ResultSet; NULL if it is an integer.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.
See Also:
execute(java.lang.String)

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Returns the current result, which should be an integer value. This method should only be called once per result.

Specified by:
getUpdateCount in interface java.sql.Statement
Returns:
The current result as an integer.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.
See Also:
execute(java.lang.String)

setDescribe

protected void setDescribe(boolean describe)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

isDescribe

protected boolean isDescribe()
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
Moves to a Statement's next result. This method always returns False because SAS software does not support multiple ResultSets. The method also implicitly closes any current ResultSet obtained with getResultSet().

Specified by:
getMoreResults in interface java.sql.Statement
Returns:
True if the next result is a ResultSet; False if it is an integer.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.
See Also:
execute(java.lang.String)

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException
JDBC 2.0 Gives a hint as to the direction in which the rows in the result set created by this statement will be processed. Currently, the rows of the resultset will be processed only in the forward direction.

Specified by:
setFetchDirection in interface java.sql.Statement
Parameters:
direction - An integer indicating the direction in which the rows of the result set will be processed. Currently supports only FETCH_FORWARD.
Throws:
java.sql.SQLException - This exception is thrown if the fetch direction is not FETCH_FORWARD.

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException
JDBC 2.0 Gets the fetch direction for the result set created by this statement. The rows of the resultset will be processed only in forward direction.

Specified by:
getFetchDirection in interface java.sql.Statement
Returns:
An integer value indicating FETCH_FORWARD.
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException
JDBC 2.0 Sets the number of rows to be fetched. Note 1: The integer fetchSize is casted to a short and so fetch size value might get truncated to 2 bytes. Note 2: The performance hint is ignored if you are connected to a V6 SAS/SHARE server. Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified only affects result sets created using this statement. If the value specified is zero, then the hint is ignored.

Specified by:
setFetchSize in interface java.sql.Statement
Parameters:
rows - The number of rows to fetch.
Throws:
java.sql.SQLException - This exception is thrown if a database-access error occurs, or the condition 0 <= rows <= this.getMaxRows() is not satisfied.

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException
JDBC 2.0 Gets the number of rows to be fetched.

Specified by:
getFetchSize in interface java.sql.Statement
Returns:
The number of rows to be fetched.
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
JDBC 2.0 Gets the result set concurrency type CONCUR_READ_ONLY as the resultset is a READ ONLY resultset.

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Returns:
An int concurrency type of the resultset CONCUR_READ_ONLY.
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
JDBC 2.0 Gets the result set type TYPE_FORWARD_ONLY as scrolling is not supported.

Specified by:
getResultSetType in interface java.sql.Statement
Returns:
An int result set type TYPE_FORWARD_ONLY.
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
JDBC 2.0 Adds a SQL command to the current batch of commmands for the statement. This method is not yet supported.

Specified by:
addBatch in interface java.sql.Statement
Parameters:
sql - Typically this is a static SQL INSERT or UPDATE statement.
Throws:
java.sql.SQLException - This exception is always thrown.

clearBatch

public void clearBatch()
                throws java.sql.SQLException
JDBC 2.0 Clears the set of commands in the current batch. This method is not yet supported.

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException - This exception is always thrown.

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException
JDBC 2.0 Submits a batch of commands to the database for execution. This method is not yet supported.

Specified by:
executeBatch in interface java.sql.Statement
Returns:
An array of update counts containing one element for each command in the batch. The array is ordered according to the order in which commands were inserted into the batch.
Throws:
java.sql.SQLException - This exception is always thrown.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
JDBC 2.0 Gets the Connection that produced this Statement.

Specified by:
getConnection in interface java.sql.Statement
Returns:
The Connection that produced this Statement.
Throws:
This - exception is required by the interface but it is never thrown.
java.sql.SQLException

addWarning

public void addWarning(java.sql.SQLWarning warning)
Adds a warning to this Statement.

Parameters:
warning - The warning to add to this statement.

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
The method is not implemented at this time. Moves to this Statement object's next result, dealing with any current ResultSet object(s) according to the instructions specified by the given flag.

Specified by:
getMoreResults in interface java.sql.Statement
Parameters:
current - a Statement constants indicating how current ResultSet objects be dealt with.
Throws:
java.sql.SQLException - always thrown. This method is not supported by this driver.

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement object did not generate any keys, an empty ResultSet object is returned. This method is not implemented in this driver.

Specified by:
getGeneratedKeys in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

executeUpdate

public int executeUpdate(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. This method is not implemented.

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

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. This method is not implemented in this driver.

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

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. This method is not implemented in this driver.

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

execute

public boolean execute(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. This method is not implemented in this driver.

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException
Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an INSERT statement. This method is not implemented.

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException
Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. This array contains the names of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an INSERT statement. This method is not implemented.

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException - always thrown.

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
Retrieves the result set holdability for ResultSet objects generated by this Statement object. This method is not implemented.

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

findFirstString

protected int findFirstString(java.lang.String stmt,
                              java.lang.String token,
                              int offset)

finalize

protected void finalize()
                 throws java.lang.Throwable
Protected method which cleans up state associated with this object.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - required. Not created in this method.

prepareDescribe

protected void prepareDescribe(java.lang.String statement)
                        throws ShareNetException
Open up a new query (select statement).

Parameters:
statement - select statement, e.g., "select * from lib.name"
Throws:
ShareNetException - if an IOException is detected

prepare

protected void prepare(java.lang.String statement)
                throws ShareNetException
Open up a new query (select statement).

Parameters:
statement - select statement, e.g., "select * from lib.name"
Throws:
ShareNetException - if an IOException is detected

describe

protected void describe()
                 throws ShareNetException
Open up a new query (select statement).

Throws:
ShareNetException - if an IOException is detected

destroy

protected void destroy()
                throws ShareNetException
Destroy a query object.

Throws:
ShareNetException - if an IOException is detected

numFields

public int numFields()
Return the number of fields in the query.

Returns:
number of fields

fieldNames

public java.lang.String[] fieldNames()
Find the names of all the fields in the query.

Returns:
name array

fieldType

public int fieldType(int i)
Find the type of all the fields in the query.

Returns:
label array

fieldFormat

public java.lang.String fieldFormat(int i)
Find the type of all the fields in the query.

Returns:
label array

getAns

protected com.sas.net.sharenet.Xhrspa3 getAns()
Gets the state of the query.

Returns:
ans A Xhrspa3 value.
Throws:
ShareNetException - This exception is never thrown.

getVars

protected com.sas.net.sharenet.SqlFieldArray getVars()
Gets the state of the query.

Returns:
vars A SqlFieldArray value containing all available variables attributes.
Throws:
ShareNetException - This exception is never thrown.

setVars

protected void setVars(com.sas.net.sharenet.SqlFieldArray vars)
Gets the state of the query.

Throws:
ShareNetException - This exception is never thrown.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.