Firebird 1.5:使用Java比较Blob
我需要比较blob的内容(如果它已经存在于数据库中),然后再使用Java保存它 以下是我迄今为止所做的工作:Firebird 1.5:使用Java比较Blob,java,firebird,Java,Firebird,我需要比较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 = ?");
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内部错误
错误
请帮忙。提前感谢。如果您查看,您收到的错误代码是badblk(坏块),这意味着您的字节[]可能大小/形式错误,无法作为ByteArrayInputStream正确读取,但这取决于getBLOB\u Content()
查询的参数索引不应该是1而不是0吗?根据Firebird 2.5语言参考中的这一点,只有Firebird 2.0之后才支持blob内容的相等性比较。在此之前,比较通过使用blob ID(blob的存储位置)检查它们是否是相同的blob。谢谢,我将索引更新为1,getBLOB_Content()基本上返回一个字符串。我不确定Firebird 1.5是否支持blob的比较,这可能是一个原因。您可以检查stacktrace是否包含更具体的错误吗?是否有任何关于如何按blob ID进行比较的示例?这种比较并不是很有用:blob ID是blob的标识。一个新的BLUB永远不会有与旧BLB相同的ID。考虑升级到FieldBew 2.5,它只存在了三年;由于公司原因,我无法升级到firebird版本…:(还有其他方法可以比较Firebrid 1.5中的blob吗?@iant FreeAdhocUDF提供了一个UDF,允许您