Some implementations of ``++java.sql.ResultSet#getMetaData()++`` suffer from performance issue and should not be called in a loop. Instead, multiple calls in a row should be replaced by a single cached call.


== Noncompliant Code Example

[source,java]
----
ResultSetMetaData rsmd = rs.getMetaData();
for (int i=1; i<rsmd.getColumnCount(); i++) {
  System.out.println(rs.getMetaData().getAutoIncrement()); // Noncompliant; "rs.getMetaData()" will be called for each columns
}
----


== Compliant Solution

[source,java]
----
ResultSetMetaData rsmd = rs.getMetaData(); // Compliant; result of "rs.getMetaData()" is cached
for (int i=1; i<rsmd.getColumnCount(); i++) {
  System.out.println(rsmd.getAutoIncrement());
}
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::message.adoc[]

endif::env-github,rspecator-view[]
