gpt4 book ai didi

java - 无法使用 dropjava 命令从 Oracle 数据库中删除 jar

转载 作者:行者123 更新时间:2023-12-02 05:37:51 25 4
gpt4 key购买 nike

我正在尝试执行 dropjava 命令以在数据库中删除一个 jar 文件....

dropjava -u username/password@schema -v -r abc.jar 

...但它给了我以下错误:

ORA-29537: class or resource cannot be created or dropped directly

问题是什么?

我使用这个命令加载了 JAR:

loadjava -u username/password@schema -v -r -f abc.jar 

最佳答案

TL;DR:定义相同类的 Java 源对象 (object_type='JAVA SOURCE') 已存在于数据库中。先放下它。


$ oerr ora 29537

29537, 00000, "class or resource cannot be created or dropped directly"
// *Cause: An attempt was made to create or drop a Java class or resource that
// is known to result from compilation of an existing Java source object.
// *Action: Act on the class or resource by acting on the source, or change
// the source so that it no longer defines the class or resource.

考虑以下 MCVE:

$ echo "public class SomeClass { }" >SomeClass.java
$ javac SomeClass.java
$ jar -cvf SomeClass.jar SomeClass.class
$ conndb="user/pass@db_server/sevice_name"

$ loadjava -u $conndb -r -v SomeClass.jar
resolving: class SomeClass
Classes Loaded: 1

$ dropjava -u $conndb -v SomeClass.jar
dropping: class SomeClass

到目前为止,还不错。现在,让我们创建定义相同类的 java 源对象:

$ sqlplus -l -s $conndb <<+++
create or replace and compile java source named "SomeClass" as
$(<SomeClass.java)
/
+++
Java created.

那么类既不能直接创建也不能直接删除:

$ loadjava -u $conndb -r -v SomeClass.jar
Error while creating class SomeClass
ORA-29537: class or resource cannot be created or dropped directly

$ dropjava -u $conndb -v SomeClass.jar
Error while dropping SomeClass
ORA-29537: class or resource cannot be created or dropped directly

删除定义同名类的现有 java 源代码,它将再次工作:

$ sqlplus -l -s $conndb <<+++
drop java source SomeClass;
+++
Java dropped.

$ loadjava -u $conndb -r -v SomeClass.jar
resolving: class SomeClass
Classes Loaded: 1

$ dropjava -u $conndb -v SomeClass.jar
dropping: class SomeClass

关于java - 无法使用 dropjava 命令从 Oracle 数据库中删除 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11410865/

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