public void readData(RowSetInternal caller) throws SQLException
    {
        Connection con = null;
        try {
            CachedRowSet crs = (CachedRowSet)caller;

            // Get rid of the current contents of the rowset.

            /**
             * Checking added to verify whether page size has been set or not.
             * If set then do not close the object as certain parameters need
             * to be maintained.
             */

            if(crs.getPageSize() == 0 && crs.size() >0 ) {
               // When page size is not set,
               // crs.size() will show the total no of rows.
               crs.close();
            }

            writerCalls = 0;

            // Get a connection.  This reader assumes that the necessary
            // properties have been set on the caller to let it supply a
            // connection.
            userCon = false;

            con = this.connect(caller);

            // Check our assumptions.
            if (con == null || crs.getCommand() == null)
                throw new SQLException(resBundle.handleGetObject("crsreader.connecterr").toString());

            try {
                con.setTransactionIsolation(crs.getTransactionIsolation());
            } catch (Exception ex) {
                ;
            }
            // Use JDBC to read the data.
            PreparedStatement pstmt = con.prepareStatement(crs.getCommand());
            // Pass any input parameters to JDBC.

            decodeParams(caller.getParams(), pstmt);
            try {
                pstmt.setMaxRows(crs.getMaxRows());
                pstmt.setMaxFieldSize(crs.getMaxFieldSize());
                pstmt.setEscapeProcessing(crs.getEscapeProcessing());
                pstmt.setQueryTimeout(crs.getQueryTimeout());
            } catch (Exception ex) {
                /*
                 * drivers may not support the above - esp. older
                 * drivers being used by the bridge..
                 */
                throw new SQLException(ex.getMessage());
            }

            if(crs.getCommand().toLowerCase().indexOf("select") != -1) {
                // can be (crs.getCommand()).indexOf("select")) == 0
                // because we will be getting resultset when
                // it may be the case that some false select query with
                // select coming in between instead of first.

                // if ((crs.getCommand()).indexOf("?")) does not return -1
                // implies a Prepared Statement like query exists.

                ResultSet rs = pstmt.executeQuery();
               if(crs.getPageSize() == 0){
                      crs.populate(rs);
               }
               else {
                       /**
                        * If page size has been set then create a ResultSet object that is scrollable using a
                        * PreparedStatement handle.Also call the populate(ResultSet,int) function to populate
                        * a page of data as specified by the page size.
                        */
                       pstmt = con.prepareStatement(crs.getCommand(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                       decodeParams(caller.getParams(), pstmt);
                       try {
                               pstmt.setMaxRows(crs.getMaxRows());
                               pstmt.setMaxFieldSize(crs.getMaxFieldSize());
                               pstmt.setEscapeProcessing(crs.getEscapeProcessing());
                               pstmt.setQueryTimeout(crs.getQueryTimeout());
                           } catch (Exception ex) {
                          /*
                           * drivers may not support the above - esp. older
                           * drivers being used by the bridge..
                           */
                            throw new SQLException(ex.getMessage());
                          }
                       rs = pstmt.executeQuery();
                       crs.populate(rs,startPosition);
               }
                rs.close();
            } else  {
                pstmt.executeUpdate();
            }

            // Get the data.
            pstmt.close();
            try {
                con.commit();
            } catch (SQLException ex) {
                ;
            }
            // only close connections we created...
            if (getCloseConnection() == true)
                con.close();
        }
        catch (SQLException ex) {
            // Throw an exception if reading fails for any reason.
            throw ex;
        } finally {
            try {
                // only close connections we created...
                if (con != null && getCloseConnection() == true) {
                    try {
                        if (!con.getAutoCommit()) {
                            con.rollback();
                        }
                    } catch (Exception dummy) {
                        /*
                         * not an error condition, we're closing anyway, but
                         * we'd like to clean up any locks if we can since
                         * it is not clear the connection pool will clean
                         * these connections in a timely manner
                         */
                    }
                    con.close();
                    con = null;
                }
            } catch (SQLException e) {
                // will get exception if something already went wrong, but don't
                // override that exception with this one
            }
        }
    }
Reads data from a data source and populates the given
<code>RowSet</code> object with that data.
This method is called by the rowset internally when
the application invokes the method <code>execute</code>
to read a new set of rows.
<P>
After clearing the rowset of its contents, if any, and setting
the number of writer calls to <code>0</code>, this reader calls
its <code>connect</code> method to make
a connection to the rowset's data source. Depending on which
of the rowset's properties have been set, the <code>connect</code>
method will use a <code>DataSource</code> object or the
<code>DriverManager</code> facility to make a connection to the
data source.
<P>
Once the connection to the data source is made, this reader
executes the query in the calling <code>CachedRowSet</code> object's
<code>command</code> property. Then it calls the rowset's
<code>populate</code> method, which reads data from the
<code>ResultSet</code> object produced by executing the rowset's
command. The rowset is then populated with this data.
<P>
This method's final act is to close the connection it made, thus
leaving the rowset disconnected from its data source.

@param caller a <code>RowSet</code> object that has implemented
              the <code>RowSetInternal</code> interface and had
              this <code>CachedRowSetReader</code> object set as
              its reader
@throws SQLException if there is a database access error, there is a
        problem making the connection, or the command property has not
        been set
src/main/java/org/replicadb/rowset/sun/rowset/internal/CachedRowSetReader.java