English 中文(简体)
如何解决FindBugs的警告:“准备的声明产生于一种非常规的强硬”。
原标题:How to resolve FindBugs Warning "A prepared statement is generated from a nonconstant String"?

我有以下法典,FindBugs抱怨说,“准备的声明产生于第二行的一条非固定的指令”。 我试图宣布“sql New”为final,但确实没有帮助。 我没有操纵任何其他地方的扼杀。 我如何摆脱这一警告?

String sqlNew = "insert into table (itemkey, attribute, value, updateddate, updatedby)  values (?, ?, ?, getDate(),   )";
stmtNew = conn.prepareStatement(sqlNew);
问题回答

我建议,使用“无”一词,宣布插座为“<条码>,使用“无”一词,在您的级别上可变。 CAPS 命名公约:

private static final String SQL_NEW = "insert into table (itemkey, attribute, value, updateddate, updatedby)  values (?, ?, ?, getDate(),   )";

错误正试图找到你做的事情。

String query = "insert into table (itemkey, attribute, value, updateddate, updatedby)  values (?, ?, ?, " + getDate() + ",   )";

这就是说扼杀。 它与最终决定毫无关系。

Findbugs正在预计该座标将装上最不发达国家指示,而没有任何StingBuilder行动。 原因是,如果你这样做的话,你可以jection。

你的榜样是完美的。 你们是否确信,确切地说,那些发现有争议的守则是反的? 如果是,它就在FindBugs。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签