include::../description.adoc[]


== Noncompliant Code Example

[source,kotlin]
----
val ps: PreparedStatement = con.prepareStatement("SELECT fname, lname FROM employees where hireDate > ? and salary < ?")
ps.setDate(0, date) // Noncompliant
ps.setDouble(3, salary) // Noncompliant

val rs: ResultSet = ps.executeQuery()
while (rs.next()) {
    val fname: String = rs.getString(0) // Noncompliant
    // ...
}
----


== Compliant Solution

[source,kotlin]
----
val ps: PreparedStatement = con.prepareStatement("SELECT fname, lname FROM employees where hireDate > ? and salary < ?")
ps.setDate(1, date)
ps.setDouble(2, salary)

val rs: ResultSet = ps.executeQuery()
while (rs.next()) {
  val fname: String = rs.getString(1)
  // ...
}
----


