简体   繁体   English

无法在 Oracle 中使用 dbms_java.loadjava 加载 jar

[英]Unable to load jar using dbms_java.loadjava in Oracle

I need to upload a jar file in Oracle RDBMS using dbms_java.loadjava method.我需要使用dbms_java.loadjava方法在 Oracle RDBMS 中上传 jar 文件。 I have granted all the required permission and able to run below function successfully.我已授予所有必需的权限,并且能够成功运行以下功能。

create or replace function get_java_property(prop in varchar2)
return varchar2 is
language java name 'java.lang.System.getProperty(java.lang.String) return java.lang.String';

select get_java_property('java.version') from dual;

1.8.0_231

However, I also need to upload an external jar and use the same.但是,我还需要上传一个外部 jar 并使用它。 I am successfully able to do the same by placing jar on Oracle Server and running loadjava command.通过将 jar 放在 Oracle Server 上并运行loadjava命令,我可以成功地做到这一点。 However I want to do the same using dbms_java.loadjava from my local system.但是,我想使用本地系统中的dbms_java.loadjava来做同样的事情。 I am trying following query.我正在尝试以下查询。

call dbms_java.loadjava('–proxy -Dhttp.proxyHost=my_local_system_ip -Dhttp.proxyPort=22 file:///home/Documents/abc.jar');

Its returning Call completed.它的返回Call completed. However, jar is not uploaded as I have tried to access methods in Jar and getting error但是,jar 未上传,因为我尝试访问 Jar 中的方法并出现错误

ORA-29540: class com/pkg_name/function_name does not exist
29540. 00000 -  "class %s does not exist"  
*Cause:    Java method execution failed to find a class with the indicated name.
*Action:   Correct the name or add the missing Java class.

However same methods are accessible when jar is uploaded through loadjava command.但是,当通过loadjava命令上传 jar 时,可以使用相同的方法。 Please suggest.请建议。 May be I am missing some basics.可能是我缺少一些基础知识。

When loading from a local file you don't have to use the -proxy switch:从本地文件加载时,您不必使用 -proxy 开关:

call dbms_java.loadjava('//home/Documents/abc.jar');

Note: The path must reside on the database server machine注意:路径必须位于数据库服务器机器上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM