java - 参数中的PreparedStatement setBigDecimal

标签 java jdbc prepared-statement bigdecimal

我有带保存方法的 DAO

public void save(BigDecimal cashBackAmount){
 try (Connection connection = dataSource.getConnection();
             PreparedStatement stmt = connection.prepareStatement(query)) {
             stmt.setBigDecimal(1, cashBackAmount);
             stmt.executeUpdate();
        } catch (SQLException e) {
            log.error(e.getMessage());
            throw e;
        }
    }
}

findbug 说:

FindBugs: Unchecked/unconfirmed cast This cast is unchecked, and not all instances of the type casted from can be cast to the type it is being cast to. Check that your program logic ensures that this cast will not fa

如何设置BigDecimal?

stmt.setBigDecimal(1, new BigDecimal(????));

最佳答案

忽略警告/错误。在这种情况下,该消息完全没有意义。

很明显,您已经收到了BigDecimal。因此您不可能收到其他对象。

关于java - 参数中的PreparedStatement setBigDecimal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43225004/

相关文章:

java - Netbeans persistence.xml - 持久单元路径的定义

python - 连接到 python 中的数据库 url,其中 url 用于 jdbc

java - 使用set Object()代替jdbc中的所有数据类型

java - 杀死一个挂起的线程

java - 尝试将 switch-case 与 actionlistener 一起使用

java - 如何在 Appium 测试中在 2 个不同的应用程序之间切换?

Java SQL更新语法错误

通过远程桌面进行 Java 渲染

java - 在 Java 中连接到 Microsoft Access 2007 数据库的正确方法是什么?

java - 为什么 Sybase 不使用功能索引?