tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From August Detlefsen <augustd...@yahoo.com>
Subject Re: How many rows have a ResultSet?
Date Mon, 10 Jun 2002 19:24:07 GMT
Am I correct in assuming you want the number of rows BEFORE you iterate
the result set? 

If you are using JDBC 1.2 you can do it like this (snippet): 

//declare your Statement to return a scroll insensitive result set 
//before you make the query
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

//get the number of rows by scrolling to the last row, 
//getting its number, then returning to the start: 
try {
    resultSet.last();
    numberOfRows = resultSet.getRow();
    resultSet.beforeFirst();
} catch (Exception e) {
    e.printStackTrace();
}




--- Anibal Constante Brito <aconstante_00@hotmail.com> wrote:
> > Hy,
> >
> > you can use rs.RecordCount
> >
> > Regards
> > Marcus
> 
> the ResultSet don't have this property?, sorry, but you answer don't
> help
> me.
> 
> Owen.
> 
> --
> To unsubscribe, e-mail:  
> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:tomcat-user-help@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message