no of rows selected

When I execute a "select" statement, I want to know how many rows it fetches from the database.How do I do it?
[138 byte] By [anithi78] at [2007-9-26 3:14:30]
# 1

Hi

Hi,

Using JDBC 2.0 is very easy

After creating the appropiate scrollable ResulSet;

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSet srs = stmt.executeQuery("SELECT * FROM YOUR_TABLE_NAME");

srs.afterLast();

//Retrieves the current row number.

int lastRow = srs.getRow() ;

Nieves.

npena at 2007-6-29 11:24:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
I want to do it in JDBC 1.2... Do you anyway out?
anithi78 at 2007-6-29 11:24:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
do select count(*) from table_name after your query.int no_of_rows = rs.getInt(1);But it is possible that no. of rows might have got updated during the process....
javastus at 2007-6-29 11:24:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...