The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Java Result Set - count

Hello

how can I know how many records there are in a Result Set returned by Prepared Statements executeQuery? Or at least know if it's not empty.

Thanks.
YetAnotherUsername
Sunday, April 22, 2007
 
 
I can know if its not empty with

if (rs.next()) {
}

But I want to do

if ( result set Not Empty ) {
  this.obj = result set
  return ok
}
else {
  return error
}

Note: without a second query to select count(*) 

Thanks.
YetAnotherUsername
Sunday, April 22, 2007
 
 
I guess I can do

if(res.next()){
  res.previous();
  this.obj = res;
  return ok;
}
else{
  return error_code;
}

Thanks.
YetAnotherUsername
Sunday, April 22, 2007
 
 
Glad we could help.
DJ Clayworth
Monday, April 23, 2007
 
 
if (rs.hasNext()) {
  // do something ...
}
else {
  return ERROR_CODE;
}
. Send private email
Tuesday, April 24, 2007
 
 
err, sorry ... please disregard my previous snippet!
. Send private email
Tuesday, April 24, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz