sonarqube 错误地报告 以下(简化)来源PreparedStatement has no parameters.
(squid:S2695):
public static final String UPDATE_QUERY = "UPDATE TABLE SET COL1=? WHERE PK=?";
private PreparedStatement preparedStatement = null;
public void updateMethod(Date date, Long pk )
{
if(preparedStatement == null)
{
//ConnectionService is not a Connection!
preparedStatement = ConnectionService.prepareStatement(UPDATE_QUERY);
}
//sonarqube reports on the following two lines: 'This "PreparedStatement" has no parameters.'
preparedStatement.setDate(1, date);
preparedStatement.setLong(2, pk);
ResultSet rs = preparedStatement .executeQuery();
//further code left out
}
问题:
这是分析仪的错误还是限制?
我可以采取哪些措施来隐藏这些“误报”吗?