com.ibm.as400.util.servlet

Class SQLResultSetRowData

  • All Implemented Interfaces:
    java.io.Serializable


    public class SQLResultSetRowData
    extends RowData
    The SQLResultSetRowData class represents an SQL ResultSet as a list of data. The ResultSet object is generated by an executed SQL statement.

    An SQLResultSetRowData object maintains a position in the list that points to its current row of data. The initial position in the list is set before the first row. The next method moves to the next row in the list.

    The getString method is used to retrieve the column value for the current row indexed by the column number. Columns are numbered starting from 0.

    The number, types, and properties of the list's columns are provided by the SQLResultSetMetaData object returned by the getMetaData method.

    The following example creates an SQLResultSetRowData object and initializes it to an SQL ResultSet.

      // Register and get a connection to the database.
      DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
      Connection connection = DriverManager.getConnection("jdbc:as400://mySystem");
    
      // Execute an SQL statement and get the result set.
      Statement statement = connection.createStatement();
      statement.execute("select * from qiws.qcustcdt");
      ResultSet resultSet = statement.getResultSet();
    
      // Create the SQLResultSetRowData object and initialize to the result set.
      SQLResultSetRowData rowData = new SQLResultSetRowData(resultSet);
      
    See Also:
    Serialized Form
    • Field Detail

      • resultSet_

        protected transient java.sql.ResultSet resultSet_
        The java.sql.ResultSet object associated with this RowData.
    • Constructor Detail

      • SQLResultSetRowData

        public SQLResultSetRowData()
        Constructs a default SQLResultSetRowData object.
      • SQLResultSetRowData

        public SQLResultSetRowData(java.sql.ResultSet resultSet)
                            throws RowDataException
        Constructs a SQLResultSetRowData object with the specified resultSet. The remaining rows are read from the ResultSet starting at the current cursor position. The ResultSet is left in an open state with the cursor positioned after the last row. The ResultSet can be closed using the close method.
        Parameters:
        resultSet - The SQL result set. An empty result set is invalid.
        Throws:
        RowDataException - If the cursor state of the result set is invalid or a rowdata error occurs.
        See Also:
        close()
    • Method Detail

      • getResultSet

        public java.sql.ResultSet getResultSet()
        Returns the SQL result set. Null is returned if the object was serialized. The result set data is cached during serialization.
        Returns:
        The SQL result set.
      • setResultSet

        public void setResultSet(java.sql.ResultSet resultSet)
                          throws RowDataException,
                                 java.beans.PropertyVetoException
        Sets the SQL result set. The remaining rows are read from the ResultSet starting at the current cursor position. The ResultSet is left in an open state with the cursor positioned after the last row. The ResultSet can be closed using the close method. If a result set already exists, then setting the result set will remove all rows from the list before reading in the new data.
        Parameters:
        resultSet - The SQL result set. An empty result set is invalid.
        Throws:
        RowDataException - If the cursor state of the result set is invalid or a rowdata error occurs.
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        close()