tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Power-Netz \(Schwarz\)" <schw...@power-netz.de>
Subject AW: How many rows have a ResultSet?
Date Wed, 12 Jun 2002 09:48:45 GMT
> 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();
> }

This will only work, IF the underlying driver really supports all methods
offered by JDBC. !this is not for sure! -> see ORACLE who did not implement
all resultset navigation methods.




--
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