I have something like this:
PreparedStatement ps;
// ...
public static final String sqlQuery = "select * from users where user_id = ?";
public ResultSet getResultData(int id) {
ps = conn.prepareStatement(sqlQuery); // SpotBugs warning here
ps.setInteger(1, id);
return ps.executeQuery();
}
SpotBugs says next:
This use of java/sql/Connection.prepareStatement(Ljava/lang/String;)Ljava/sql/PreparedStatement; can be vulnerable to SQL injection (with JDBC)
And suggest already implemented solution.
Is that false positive warning and should be suppressed or did I miss something?