-1

我知道,因为PreparedStatement我需要将 SQL 表达式输入PreparedStatement像这样

 String updateStatement =
        "update " + dbName + ".COFFEES " +
        "set TOTAL = TOTAL + ? " +
        "where COF_NAME = ?";

但是,我可以在没有“?”的情况下使用完整的 where 子句来提供更新语句?

例如

 String updateStatement =
        "update " + dbName + ".COFFEES " +
        "set TOTAL = TOTAL + ? " +
        "where COF_NAME = 'aaa";

这只是因为我where在我的函数中获得了作为参数,并且我认为解析字符串以将其分解并不有效。

4

1 回答 1

0

使用准备好的语句的目的是拥有动态变量,但是当您询问是否可以对整个 where 子句进行硬编码时,是的,您可以对其进行硬编码。

于 2016-06-04T17:56:42.360 回答