SQLServer eWay API

com.stc.connector.sqlserveradapter.base
Class TableResultSetImpl

java.lang.Object
  extended by com.stc.connector.sqlserveradapter.base.StatementAgentImpl
      extended by com.stc.connector.sqlserveradapter.base.TableResultSetImpl
All Implemented Interfaces:
com.stc.connector.appconn.db.StatementAgent, com.stc.connector.appconn.db.TableResultSet, com.stc.connector.db.SessionEventListener
Direct Known Subclasses:
SqlserverTableResultSet

public class TableResultSetImpl
extends StatementAgentImpl
implements com.stc.connector.appconn.db.TableResultSet

ResultSet to map selected records of table in the database.

Version:
$Revision: 1.7 $
Author:
$Author: pveerava $

Field Summary
 
Fields inherited from class com.stc.connector.sqlserveradapter.base.StatementAgentImpl
concurrencyType, listener, resultSetConcurMap, resultsetDirection, resultSetDirMap, resultsetType, resultSetTypeMap, session, sqlException, statement, statementClassName
 
Constructor Summary
TableResultSetImpl(com.stc.connector.db.Session session)
          TableResultSetImpl constructor.
TableResultSetImpl(com.stc.connector.db.Session session, int iScroll, int iConcur)
          TableResultSetImpl constructor.
 
Method Summary
 boolean absolute(int row)
          Moves the cursor to the specified row of the result set.
 void afterLast()
          Moves the cursor after the last row of the result set.
 void beforeFirst()
          Moves the cursor before the first row of the result set.
 void cancelRowUpdates()
          Cancels any updates made to this row.
 void clearWarnings()
          Clears any warnings reported on this object.
 void closeResultSet()
          Immediately releases ResultSet object's resources, close the cursor.
 int delete(java.lang.String sWhere)
          Delete table records according to the where condition if any.
 void deleteRow()
          Deletes the contents of the current row from the database.
 int executeUpdate(java.lang.String sqlStatement)
           
 int findColumn(java.lang.String index)
          Returns the column index for the named column in the result set.
 boolean first()
          Moves the cursor to the first row of the result set.
 java.io.InputStream getAsciiStream(int index)
          Retrieves the value of the specified column vlaue as a stream of ASCII characters.
 java.io.InputStream getAsciiStream(java.lang.String columnName)
          Retrieves the value of the specified column as a stream of ASCII characters.
 java.io.InputStream getBinaryStream(int index)
          Retrieves the value of the specified column as a stream of uninterpreted bytes.
 java.io.InputStream getBinaryStream(java.lang.String columnName)
          Retrieves the value of the specified column as a stream of uninterpreted bytes.
 java.io.Reader getCharacterStream(int index)
          Retrieves the value of the specified column as a Reader object.
 java.io.Reader getCharacterStream(java.lang.String columnName)
          Retrieves the value of the specified column as a Reader object.
 int getRow()
          Retrieves the current row number in the result set.
 com.stc.connector.appconn.db.ResultSetAgent getRSAgent()
          Gets the ResultSetAgent that holds the resultset.
 void insert()
          Prepares a SQL statement for insert.
 void insertRow()
          Inserts the contents of the current row into the database.
 boolean isAfterLast()
          Determines whether the cursor is after the last row of the result set.
 boolean isBeforeFirst()
          Determines whether the cursor is before the first row of the result set.
 boolean isFirst()
          Determines whether the cursor is on the first row of the result set.
 boolean isLast()
          Determines whether the cursor is on the last row of the result set.
 boolean last()
          Moves the cursor to the last row of the result set.
 void moveToCurrentRow()
          Moves the current position to the current row.
 void moveToInsertRow()
          Moves the current position to a new insert row.
 boolean next()
          Moves the cursor to the next row of the result set.
 boolean previous()
          Moves the cursor to the previous row of the result set.
 void refreshRow()
          Refreshes the current row with its most recent value from the database.
 boolean relative(int rows)
          Moves the cursor to the specified row relative to current row of the result set.
 boolean rowDeleted()
          Checks if the current row has been deleted.
 boolean rowInserted()
          Checks if the current row has been inserted.
 boolean rowUpdated()
          Checks if the current row has been updated.
 void select(java.lang.String sWhere)
          Select table records according to the where condition if any.
 void sessionClose(com.stc.connector.db.SessionEvent evt)
          Processes sessionClose event.
 void sessionReset(com.stc.connector.db.SessionEvent evt)
          Processes sessionReset event.
 void setColumns(java.lang.String[] columns)
          Specifies the desired columns of the table.
 void setTable(java.lang.String table)
          Sets the name of the table that is being processed.
 void update(java.lang.String sWhere)
          Update table records according to the where condition if any.
 void updateRow()
          Updates the contents of the current row into the database.
 boolean wasNull()
          Checks if the last data retrieved is NULL.
 
Methods inherited from class com.stc.connector.sqlserveradapter.base.StatementAgentImpl
cancel, clearBatch, executeBatch, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, isClosed, queryName, resultSetConcurToString, resultSetDirToString, resultSetTypeToString, sessionOpen, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout, stmtInvoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.stc.connector.appconn.db.StatementAgent
cancel, clearBatch, executeBatch, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, isClosed, queryName, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout, stmtInvoke
 

Constructor Detail

TableResultSetImpl

public TableResultSetImpl(com.stc.connector.db.Session session)
TableResultSetImpl constructor.

Parameters:
session - a Session instance for accessing connection and creating necessary resources.

TableResultSetImpl

public TableResultSetImpl(com.stc.connector.db.Session session,
                          int iScroll,
                          int iConcur)
TableResultSetImpl constructor.

Parameters:
session - a Session instance for accessing connection and creating necessary resources.
iScroll - resultset type; TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
iConcur - concurrency type; CONCUR_READ_ONLY, CONCUR_UPDATABLE
Method Detail

select

public void select(java.lang.String sWhere)
            throws java.sql.SQLException
Select table records according to the where condition if any.

Specified by:
select in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
sWhere - the where clause
Throws:
java.sql.SQLException - when failing to execute the query.

delete

public int delete(java.lang.String sWhere)
           throws java.sql.SQLException
Delete table records according to the where condition if any.

Specified by:
delete in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
sWhere - the where clause
Returns:
the number of deleted rows.
Throws:
java.sql.SQLException - when failing to execute the delete operation.

update

public void update(java.lang.String sWhere)
            throws java.sql.SQLException
Update table records according to the where condition if any. Using updateable result set to perform update operations.

Specified by:
update in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
sWhere - the where clause
Throws:
java.sql.SQLException - when failing to execute the delete operation.

next

public boolean next()
             throws java.sql.SQLException
Moves the cursor to the next row of the result set.

Specified by:
next in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if successful; false if there is no more row.
Throws:
java.sql.SQLException - when SQL problems occur.

previous

public boolean previous()
                 throws java.sql.SQLException
Moves the cursor to the previous row of the result set.

Specified by:
previous in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

absolute

public boolean absolute(int row)
                 throws java.sql.SQLException
Moves the cursor to the specified row of the result set.

Specified by:
absolute in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
row - the row index.
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

relative

public boolean relative(int rows)
                 throws java.sql.SQLException
Moves the cursor to the specified row relative to current row of the result set.

Specified by:
relative in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
rows - number of rows relative to the currentone.
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

first

public boolean first()
              throws java.sql.SQLException
Moves the cursor to the first row of the result set.

Specified by:
first in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

isFirst

public boolean isFirst()
                throws java.sql.SQLException
Determines whether the cursor is on the first row of the result set.

Specified by:
isFirst in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

last

public boolean last()
             throws java.sql.SQLException
Moves the cursor to the last row of the result set.

Specified by:
last in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if successful; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

isLast

public boolean isLast()
               throws java.sql.SQLException
Determines whether the cursor is on the last row of the result set.

Specified by:
isLast in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the cursor is in the last row;false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

beforeFirst

public void beforeFirst()
                 throws java.sql.SQLException
Moves the cursor before the first row of the result set.

Specified by:
beforeFirst in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

isBeforeFirst

public boolean isBeforeFirst()
                      throws java.sql.SQLException
Determines whether the cursor is before the first row of the result set.

Specified by:
isBeforeFirst in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the cursor is before the first row; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

afterLast

public void afterLast()
               throws java.sql.SQLException
Moves the cursor after the last row of the result set.

Specified by:
afterLast in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

isAfterLast

public boolean isAfterLast()
                    throws java.sql.SQLException
Determines whether the cursor is after the last row of the result set.

Specified by:
isAfterLast in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the cursor is after the last row; false otherwise.
Throws:
java.sql.SQLException - when SQL problems occur.

findColumn

public int findColumn(java.lang.String index)
               throws java.sql.SQLException
Returns the column index for the named column in the result set.

Specified by:
findColumn in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
index - the column name.
Returns:
the column index for the named column.
Throws:
java.sql.SQLException - when SQL problems occur.

getAsciiStream

public java.io.InputStream getAsciiStream(int index)
                                   throws java.sql.SQLException
Retrieves the value of the specified column vlaue as a stream of ASCII characters.

Specified by:
getAsciiStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
index - the column index.
Returns:
the Ascii stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

getAsciiStream

public java.io.InputStream getAsciiStream(java.lang.String columnName)
                                   throws java.sql.SQLException
Retrieves the value of the specified column as a stream of ASCII characters.

Specified by:
getAsciiStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
columnName - the column name.
Returns:
the Ascii stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

getBinaryStream

public java.io.InputStream getBinaryStream(int index)
                                    throws java.sql.SQLException
Retrieves the value of the specified column as a stream of uninterpreted bytes.

Specified by:
getBinaryStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
index - the column index.
Returns:
the Binary stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

getBinaryStream

public java.io.InputStream getBinaryStream(java.lang.String columnName)
                                    throws java.sql.SQLException
Retrieves the value of the specified column as a stream of uninterpreted bytes.

Specified by:
getBinaryStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
columnName - the column name.
Returns:
the Binary stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

getCharacterStream

public java.io.Reader getCharacterStream(int index)
                                  throws java.sql.SQLException
Retrieves the value of the specified column as a Reader object.

Specified by:
getCharacterStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
index - the column index.
Returns:
the Character stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

getCharacterStream

public java.io.Reader getCharacterStream(java.lang.String columnName)
                                  throws java.sql.SQLException
Retrieves the value of the specified column as a Reader object.

Specified by:
getCharacterStream in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
columnName - the column name.
Returns:
the Character stream value of the specified column.
Throws:
java.sql.SQLException - when SQL problems occur.

refreshRow

public void refreshRow()
                throws java.sql.SQLException
Refreshes the current row with its most recent value from the database.

Specified by:
refreshRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

insertRow

public void insertRow()
               throws java.sql.SQLException
Inserts the contents of the current row into the database.

Specified by:
insertRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

updateRow

public void updateRow()
               throws java.sql.SQLException
Updates the contents of the current row into the database.

Specified by:
updateRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

deleteRow

public void deleteRow()
               throws java.sql.SQLException
Deletes the contents of the current row from the database.

Specified by:
deleteRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

moveToInsertRow

public void moveToInsertRow()
                     throws java.sql.SQLException
Moves the current position to a new insert row.

Specified by:
moveToInsertRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

moveToCurrentRow

public void moveToCurrentRow()
                      throws java.sql.SQLException
Moves the current position to the current row. It is used after you insert a row.

Specified by:
moveToCurrentRow in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

cancelRowUpdates

public void cancelRowUpdates()
                      throws java.sql.SQLException
Cancels any updates made to this row.

Specified by:
cancelRowUpdates in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

rowInserted

public boolean rowInserted()
                    throws java.sql.SQLException
Checks if the current row has been inserted.

Specified by:
rowInserted in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the current row has been inserted.
Throws:
java.sql.SQLException - when SQL problems occur.

rowUpdated

public boolean rowUpdated()
                   throws java.sql.SQLException
Checks if the current row has been updated.

Specified by:
rowUpdated in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the current row has been updated.
Throws:
java.sql.SQLException - when SQL problems occur.

rowDeleted

public boolean rowDeleted()
                   throws java.sql.SQLException
Checks if the current row has been deleted.

Specified by:
rowDeleted in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the current row has been deleted.
Throws:
java.sql.SQLException - when SQL problems occur.

wasNull

public boolean wasNull()
                throws java.sql.SQLException
Checks if the last data retrieved is NULL.

Specified by:
wasNull in interface com.stc.connector.appconn.db.TableResultSet
Returns:
true if the last data retrieved is NULL.
Throws:
java.sql.SQLException - when SQL problems occur.

closeResultSet

public void closeResultSet()
                    throws java.sql.SQLException
Immediately releases ResultSet object's resources, close the cursor.

Specified by:
closeResultSet in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when SQL problems occur.

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Clears any warnings reported on this object.

Specified by:
clearWarnings in interface com.stc.connector.appconn.db.StatementAgent
Specified by:
clearWarnings in interface com.stc.connector.appconn.db.TableResultSet
Overrides:
clearWarnings in class StatementAgentImpl
Throws:
java.sql.SQLException - when SQL problems occur.

getRow

public int getRow()
           throws java.sql.SQLException
Retrieves the current row number in the result set.

Specified by:
getRow in interface com.stc.connector.appconn.db.TableResultSet
Returns:
the current row number.
Throws:
java.sql.SQLException - when SQL problems occur.

setTable

public void setTable(java.lang.String table)
Sets the name of the table that is being processed.

Specified by:
setTable in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
table - the name of the table

setColumns

public void setColumns(java.lang.String[] columns)
Specifies the desired columns of the table.

Specified by:
setColumns in interface com.stc.connector.appconn.db.TableResultSet
Parameters:
columns - an arrary of column names.

getRSAgent

public com.stc.connector.appconn.db.ResultSetAgent getRSAgent()
Gets the ResultSetAgent that holds the resultset.

Specified by:
getRSAgent in interface com.stc.connector.appconn.db.TableResultSet
Returns:
a ResultSetAgent.

sessionClose

public void sessionClose(com.stc.connector.db.SessionEvent evt)
Processes sessionClose event. This will free up preparedStatemet.

Specified by:
sessionClose in interface com.stc.connector.db.SessionEventListener
Overrides:
sessionClose in class StatementAgentImpl
Parameters:
evt - a close session event

sessionReset

public void sessionReset(com.stc.connector.db.SessionEvent evt)
Processes sessionReset event. This will free up preparedStatemet.

Specified by:
sessionReset in interface com.stc.connector.db.SessionEventListener
Overrides:
sessionReset in class StatementAgentImpl
Parameters:
evt - a close session event

insert

public void insert()
            throws java.sql.SQLException
Prepares a SQL statement for insert. After this method is called, users will call setXXX() methods before calling executeInsert().

Specified by:
insert in interface com.stc.connector.appconn.db.TableResultSet
Throws:
java.sql.SQLException - when failing to prepare the insert operation.

executeUpdate

public int executeUpdate(java.lang.String sqlStatement)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

SQLServer eWay API