rspec/rules/S2232/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

50 lines
1.1 KiB
Plaintext

== Why is this an issue?
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
[source,java]
----
stmt.executeQuery("SELECT name, address FROM PERSON");
ResultSet rs = stmt.getResultSet();
while (! rs.isLast()) { // Noncompliant
// process row
}
----
=== Compliant solution
[source,java]
----
ResultSet rs = stmt.executeQuery("SELECT name, address FROM PERSON");
while (rs.next()) {
// process row
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this call to "isLast()".
'''
== Comments And Links
(visible only on this page)
=== on 24 Nov 2014, 19:15:41 Nicolas Peru wrote:
No message.
Otherwise seems ok.
endif::env-github,rspecator-view[]