在使用 Java 保存之前,我需要比较 blob 的内容(如果它已存在于数据库中)。
以下是我到目前为止所做的:
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 异常。 335544384.内部错误
错误。
请帮忙。提前致谢。
最佳答案
如果你看at Firebird 1.5 error codes ,您收到的错误代码是 badblk(坏 block ),这意味着您的 byte[] 可能是错误的大小/格式,并且无法作为 ByteArrayInputStream 正确读取,但这取决于 getBLOB_Content()
此外,查询的参数索引不应该是 1,而不是 0?
关于java - Firebird 1.5 : Compare Blob using Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18199398/