gpt4 book ai didi

java - FindsBug 警告 :A prepared statement is generated from a nonconstant String

转载 作者:行者123 更新时间:2023-11-30 07:58:05 24 4
gpt4 key购买 nike

我收到了 findbug 警告,例如“从非常量字符串生成准备好的语句”。我的场景如下

//My code
public static int updateSQL(String sql) throws StoreException {
PreparedStatement statement = null;
statement = connection.prepareStatement(sql); //shows violation here
}

我通过方法的参数得到“sql”。如何纠正此警告?请帮助我解决此问题。

最佳答案

好吧,在这种情况下我建议忽略这个警告。它的优先级较低。这种特定错误模式的低优先级报告实际上大多是垃圾。在我看来,不应该报告它,因为 FindBugs 能够更进一步,查看 updateSQL 方法是否始终使用常量字符串调用(在这种情况下没有问题)或不(在这种情况下)将报告使用非常量字符串的具体位置)。我提交了bug report到我们的跟踪器。

关于java - FindsBug 警告 :A prepared statement is generated from a nonconstant String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32373457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com