gpt4 book ai didi

java - 在不向数据库插入任何内容的情况下初始化 OrdImage 对象

转载 作者:搜寻专家 更新时间:2023-10-30 19:44:05 25 4
gpt4 key购买 nike

由于在 IMGSimilar 运算符中出于搜索目的在 OrdImageSinature 创建中使用了对偶表(从对偶中选择 ordsys.ordimage.init()),因此我正在尝试使用对偶表的选择从 Oracle 数据库中检索 OrdImage 对象。问题是,在 ORDImage 代理中存储数据后,出现此错误:

java.sql.SQLException: ORA-22275: invalid LOB locator specified
ORA-06512: at "SYS.DBMS_LOB", line 797
ORA-06512: at "ORDSYS.ORDSOURCE", line 778
ORA-06512: at "ORDSYS.ORDIMAGE", line 508
ORA-06512: at line 1

我的代码如下:

Statement statement = connection.createStatement();
OracleResultSet result = (OracleResultSet) statement.executeQuery("SELECT ordsys.ordimage.init(), ordsys.ordimagesignature.init() FROM DUAL");

if (result.next()) {
OrdImage imageProxy = (OrdImage) result.getORAData(1, OrdImage.getORADataFactory());
OrdImageSignature imageSignatureProxy = (OrdImageSignature) result.getORAData(2, OrdImageSignature.getORADataFactory());

statement.close();
result.close();

imageProxy.loadDataFromByteArray(image.write().toByteArray()); //this line invokes error
imageProxy.setProperties();
imageSignatureProxy.generateSignature(imageProxy);

//here will be performed search operation
}

我放置在 imageProxy 中的图像本地存储在 HDD 上(它不存储在数据库中)。是否有任何变通方法如何在不创建 OrdImage 的情况下创建 OrdImageSignature 来绕过此错误或如何修复它?

非常感谢!

最佳答案

试试这段代码

// retrieve dummy Oracle Mm Java objects from the database
OrdImage imgProxy = null;
OrdImageSignature sigProxy = null;
OracleCallableStatement cstmtOrdImageCreator = (OracleCallableStatement) conn.prepareCall(
"DECLARE"
+ " IMG ORDSYS.ORDIMAGE;"
+ " SIG ORDSYS.ORDIMAGESIGNATURE;"
+ " IMGBLOB BLOB;"
+ " SIGBLOB BLOB;"
+ "BEGIN"
+ " IMG := ORDImage.init();" // init an image
+ " DBMS_LOB.CreateTemporary(IMG.source.localdata, TRUE);" // an emply BLOB for the image
+ " SIG := ORDImageSignature.init();" // init a signature of the image
+ " DBMS_LOB.CreateTemporary(SIG.signature, TRUE);" // an emply BLOB for its signature
+ " ? := IMG;" // return both the image and its signature as values of output parameters
+ " ? := SIG;"
+ "END;");
try {
cstmtOrdImageCreator.registerOutParameter(1,
OrdImage._SQL_TYPECODE, OrdImage._SQL_NAME);
cstmtOrdImageCreator.registerOutParameter(2,
OrdImageSignature._SQL_TYPECODE, OrdImageSignature._SQL_NAME);
cstmtOrdImageCreator.executeUpdate();
imgProxy = (OrdImage) cstmtOrdImageCreator.getORAData(1, OrdImage.getORADataFactory());
sigProxy = (OrdImageSignature) cstmtOrdImageCreator.getORAData(2, OrdImageSignature.getORADataFactory());
} finally {
cstmtOrdImageCreator.close();
}

关于java - 在不向数据库插入任何内容的情况下初始化 OrdImage 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7964815/

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