Javier,

You are cracking me up. Thanks.

William Louth

> -----Original Message-----
> From: Javier Borrajo [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, April 27, 2000 5:49 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Cached Rowsets-do we need to use them
>
> I agree with Richard's strategy *but* I think it lacks an important
> feature:
> paging.
>
> You may want to check the thread "Paging large database result sets"
>
> Executive summary:
> 1. provide a method to get the count of records that fit the query
> 2. provide a method to get a pge of records
>
> So instead of:
>
> public class PayRollBean implements javax.ejb.SessionBean [
>     public EJBResultSet getEmployeeSalaries( ){
>         DataSource dataSource =
> (DataSource)cntx.lookup("java:comp/env/jdbc/db");
>         Connection con = dataSource.getConnection( );
>         Statement stmt = con.createStatement( );
>         ResultSet set = stmt.executeQuery("select LNAME, FNAME, SALARY
> from
> EMPLOYEE");
>
>         CustomResultSet customSet = new CustomResultSet(set);
>         return (EJBResultSet)customSet;
>    }
>     ...
> }
>
> use:
>
> public class PayRollBean implements javax.ejb.SessionBean [
>
>   public int getEmployeeSalariesCount(){
>         DataSource dataSource =
> (DataSource)cntx.lookup("java:comp/env/jdbc/db");
>         Connection con = dataSource.getConnection( );
>         Statement stmt = con.createStatement( );
>         ResultSet set = stmt.executeQuery("select COUNT(*) from
> EMPLOYEE");
>         return set.getInt(1);
>     }
>
>     public Vector getEmployeeSalaries(int pini, int ptot){
>         DataSource dataSource =
> (DataSource)cntx.lookup("java:comp/env/jdbc/db");
>         Connection con = dataSource.getConnection( );
>         Statement stmt = con.createStatement( );
>         ResultSet set = stmt.executeQuery("select LNAME, FNAME, SALARY
> from
> EMPLOYEE");
>
>         // get a page using JDBC 1.22
>        /*int nrec = 0;
>        int tot  = pini+ptot;
>        Vector result = new Vector();
>        while( set.next() ) {
>          if ( nrec++ < pini ) continue;    // wasted effort JDBC 1.22
>          if ( (ptot>0)&&(nrec>tot) ) break;// no more records, thank you
>          result.addElement( makeAnObjectOutOfCurrentRecord() );
>        }*/
>
>         // get a page using JDBC 2.0
>        absolute(pini);
>        int nrec = 0;
>        Vector result = new Vector();
>        while( set.next() ) {
>          //if <file://if> ( nrec++ < pini ) continue; // NO wasted effort
> using JDBC 2.0
>          if ( (ptot>0)&&(++nrec>tot) ) break;// no more records, thank you
>          result.addElement( makeAnObjectOutOfCurrentRecord() );
>        }
>        return result;
>     }
>     ...
> }
>
>
> The client first asks how many records fit the query, then asks for pages
> depending on the user actions.
>
> This way we are not collapsing the client memory with thousands of records
> it does not really need.
>
> Regards
>
>     Javier
>


***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to