|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Number of rows in the select statement
I am doing a select select statement through JSP. I wan't to give number of rows in the result...
For eg.. String s1 = "SELECT id, f_name,l_name FROM login WHERE username = '"+ username +" '"; I want to display the number of rows returned.... How do I do that.... I tried... int rowsUpdated1 = theStatement.executeSelect(s1); got the following error.... Can't convert java.sql.ResultSet to int. |
|
#2
|
|||
|
|||
|
i don't know of any member functions to do this, but this should work:
Code:
public int getNumRows(ResultSet rs) {
int numRows = 0;
while(rs.next()) {
numRows++;
}
return numRows;
}
|
|
#3
|
|||
|
|||
|
Ya, I don't see anything either.
One thing you could do is add something like "count(*) as rsSize" to your sql, then get the value out of the ResultSet. This is probably faster than counting the rows. |
|
#4
|
|||
|
|||
|
that would definitely be faster...
http://www.codenotes.com/do/article...le?articleID=83 http://www.geocrawler.com/archives/...01/6/0/6062464/ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Number of rows in the select statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|