Fetching row affected by a query

Hi =)

I've my execQuery method here that returns a ResultSet of results.

I would like to know the rows returned, but I cannot find a count, lenght or size method in the ResultSet class.

縃oy can i count the number of Rows affected by a query?

public ResultSet execQuery(String consulta)

{

/*

* Variables locales

*/

ResultSet coleccion =null;

Statement stmt;

/*

* Creamos statement y ejecutamos consulta

*/

try{

stmt = conn.createStatement();

coleccion = stmt.executeQuery(consulta);

}

catch(SQLException ex)

{

this.setError(ex.toString());

returnnull;

}

// Devolvemos filas afectadas

return coleccion;

}

Thx!

[1256 byte] By [flaaba] at [2007-11-27 6:44:21]
# 1

simple answer:

stmt = conn.createStatement(ResultSet.TYPE_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

coleccion = stmt.executeQuery(consulta);

coleccion.last();

int rowCount = coleccion.getRow();

note:

1. Returning a result set is not a good idea.

2. Why you need to know rows number here. i think its useless

Message was edited by:

j_shadinata

j_shadinataa at 2007-7-12 18:15:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...