my experience is primarily with Oracle and sybase, so I don't know about mySql specific api. In the case of Oracle a person would "select myseq.nextval from dual" to get the next id.
the way that I have done it is to use a singleton bean(which all classes use) or use sequence in Oracle. The thing with using a singleton bean is if the ID absolutely has to be unique, the bean has to determine what the last ID was in the case the system is restarted. If you have 20 webservers, you'll run into more problems using a bean to generate unique reliable ID. Using sequence in the database is the most reliable way of doing it for n tier systems. IDs (or keys a more common term) are critical in RDBMS, so choosing a solution that won't scale will hurt later on. Using built in auto-increment is never recommended for real transactional applications, so if your app is transaction, don't use it. If for some reason your web application looses it's connection between the time it inserts and when you get the id out of mysql, you're in trouble. peter Soefara Redzuan wrote: > > >From: peter lin <[EMAIL PROTECTED]> > > > >The proper way to do this is to only return n number of rows. Typically > >this is done with scrollable cursors. The driver you're using has to > >support the feature. I don't see support for it in dbtags, so your other > >option is to use stored procedures or prepared statements that handle > >the cursor yourself. > > If DBTags does not support this, how are other people doing this ? This is a > basic functionality that I believe everybody uses. I think I will have to > write a scriptlet if DBTags does not have it. > > >fetching tons of rows to only display 20 will limit the scalability of > >your web application under load. > > That is what I thought. > > >Especially if your database server isn't beefy :) > > In actual fact I thought it is more of a problem with all the records being > transfered over the network unnecessarily. > > Thank you for your help Peter. > > Soefara Redzuan. > > _________________________________________________________________ > Send and receive Hotmail on your mobile device: http://mobile.msn.com > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>