There are several reasons to avoid ``++ResultSet.isLast()++``. First, support for this method is optional for ``++TYPE_FORWARD_ONLY++`` result sets. Second, it can be expensive (the driver may need to fetch the next row to answer the question). Finally, the specification is not clear on what should be returned when the ``++ResultSet++`` is empty, so some drivers may return the opposite of what is expected.


== Noncompliant Code Example

----
stmt.executeQuery("SELECT name, address FROM PERSON");
ResultSet rs = stmt.getResultSet();
while (! rs.isLast()) { // Noncompliant
  // process row
}
----


== Compliant Solution

----
ResultSet rs = stmt.executeQuery("SELECT name, address FROM PERSON");
while (rs.next()) {
  // process row
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
