Please dont use for other than stated purpose of the list. I hope you understand that.
-----Original Message----- From: soh_mah [mailto:[EMAIL PROTECTED] Sent: Thursday, May 20, 2004 10:50 AM To: Tomcat Users List Subject: RE: Is there any way to check # of Records in RecordSet Thanks Adam :) First of all I subscribe to the list yesterday and I m new to JSP. Secondly could u plz tell me right list name so I can subscribe to that. Adam, I did exactly the same way u mentioned, but when I use like //----------- ResultSet rs = stmt.executeQuery(query); while(rs.next()) { count1++; } rs.first(); //----------------- it does not show me any thing on the page but when I use like this it shows me all records. //----------- ResultSet rs = stmt.executeQuery(query); while(rs.next()) { count1++; } ResultSet rs1 = stmt.executeQuery(query); while{rs1.next()) { %> Here is HTML <% out.println(rs.getInt("first_column")); } %> //----------------- Then it shows me all the records, what is wrong with my first code? --- Adam Buglass <[EMAIL PROTECTED]> wrote: > This is the wrong list but never mind > > An alternative is the following: > > ResultSet rs; > int i = 0; > while( rs.next() ) { > i++; > } > > The integer i should be the length of your result > set (by the way, don't > get confused with RecordSets which are VB - I used > to do that all the > time!) at the end of the loop - assuming of course > that you start from > the start of the set, you could use rs.first() to > ensure this. > > There's tons of useful info on Java methods and > classes on suns site: > http://java.sun.com/j2se/1.3/docs/api/ > http://java.sun.com/j2se/1.3/ > > Also look on www.sun.com for good java mailing lists > where this kind of > question is more specific. > > Adam. > > > On Thu, 2004-05-20 at 15:26, Dale, Matt wrote: > > This is the wrong list i'm pretty sure but there > are a couple of ways to get the number but there > isnt a direct method that returns it. > > > > If the result set is scrollable you can iterate > through it counting the number of iterations, then > set it back to the start when you want to process > the records. > > > > The other option (one I prefer) is to load the > records into an ArrayList, you can then determine > the size quite easily. > > > > If anyone else has any neater solutions i'd like > to hear them too as I've had to do this in a few > places. > > > > Ta > > Matt > > > > -----Original Message----- > > From: soh_mah [mailto:[EMAIL PROTECTED] > > Sent: 20 May 2004 15:20 > > To: [EMAIL PROTECTED] > > Subject: Is there any way to check # of Records in > RecordSet > > > > > > Hi > > > > Is there any way to check number of Records in > > RecordSet? > > > > > > ===== > > Regards > > > > Sohail Mahmood > > (416) 636-2553 > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Domains - Claim yours for only $14.70/year > > http://smallbusiness.promotions.yahoo.com/offer > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > ______________________________________________________________________ > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > -- > > Adam Buglass, ><> > The Golden Freeway, > Department of Child Health, > University of Newcastle-upon-Tyne. > Royal Victoria Infirmary. > > (0191) 2023062 > > "Democracy is two wolves and a lamb voting on what > to have for lunch. > Liberty is a well-armed lamb contesting the vote." > ~Benjamin Franklin, 1759 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > ===== Regards Sohail Mahmood (416) 636-2553 __________________________________ Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year http://smallbusiness.promotions.yahoo.com/offer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]