1

如果 blob 已经存在于数据库中,我需要比较它的内容,然后再使用 Java 保存它。

以下是我到目前为止所做的:

 String id = "";
 String blob_name = "";
 boolean exist = false;
PreparedStatement ps = dbConBuilder.getConnection().prepareStatement("SELECT ID, BLOB_NAME from TBL_BLOB where BLOB_CONTENT = ?");
        InputStream in = new ByteArrayInputStream(getBLOB_Content().getBytes("UTF-8"));
        ps.setBinaryStream(1, in, (int) getBLOB_Content().length());
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            id = rs.getString("ID");
            blobname = rs.ge_tString("BLOB_NAME");
            exist = true;
        }

但我收到GDS Exception. 335544384. internal error错误。

请帮忙。提前致谢。

4

2 回答 2

0

If you look at Firebird 1.5 error codes, the error code you have been given is a badblk (Bad block) meaning that your byte[] is likely to be the wrong size/form and cannot be read correctly as a ByteArrayInputStream but that is dependent on getBLOB_Content()

Also shouldn't the parameter index for your query be 1, not 0?

于 2013-08-13T02:04:18.160 回答
0

根据 Firebird 2.5 语言参考中的这个注释,自 Firebird 2.0 起才支持 blob 内容的相等比较。在此之前,比较通过使用 blob ID(blob 的存储位置的排序)检查它们是否是同一个 blob。

于 2013-08-13T07:46:08.590 回答