gpt4 book ai didi

java - 如何将 'null' 值插入 blob 字段 (mysql)

转载 作者:行者123 更新时间:2023-11-29 00:24:20 25 4
gpt4 key购买 nike

我需要在我的数据库 mysql 的 blob 字段中插入一个“空”值。我必须在 servlet 中完成。

我试过这种方式

statement.setBlob(1,  null);

但是我得到了这个错误

The method setBlob(int, Blob) is ambiguous for the type PreparedStatement

我什至尝试过这种方式

statement.setBlob(1,  EMPTY_BLOB());

但是我得到了这个错误

The method EMPTY_BLOB() is undefined for the type Name_Of_My_Class

最佳答案

stmt.setNull(1, java.sql.Types.BLOB);

关于java - 如何将 'null' 值插入 blob 字段 (mysql),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19677448/

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