如何在Solaris上的Oracle上安装Java类

时间:2009-06-17 10:20:09

标签: java oracle

我有简单的java类来计算SHA1,我想从Oracle的PLSQL程序中使用它。 遵循以下建议: SHA1, SHA256, SHA512 in Oracle for free without using DBMS_CRYPTO (我的简单案例使用unly SHA1,不需要任何jar,只包含导入java.security和java.io的sha1.class)

我用:

编译了sha1.java
javac -target 1.2 -source 1.2 sha1.java

并在我的Windows测试环境中安装了这个sha1.class:

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

不幸的是我必须在Solaris上安装它:

Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

我试过但是那些尝试失败了:

c:\test>loadjava -thin -user ***** -resolve sha1.class
Error while creating class sha1
    ORA-29545: badly formed class:: User has attempted to load a class (sha1) into a restricted package. Permission can be granted using  dbms_java
.grant_permission(<user>, LoadClassInPackage...

The following operations failed
    class sha1: creation
exiting  : Failures occurred during processing

EDITED

我尝试使用.java源而不是.class,我得到了(从波兰语翻译)::

c:\mn>loadjava -thin -user ****** -resolve sha1.java
Error while creating sha1
    ORA-06576: not a valid function or procedure name

Error while computing shortname of sha1
    ORA-06550: line 1, column 13:
PLS-00201: must be declared 'DBMS_JAVA.SHORTNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

The following operations failed
    source sha1: creation
exiting  : Failures occurred during processing

如何在Solaris上将此类或源加载到Oracle?

2 个答案:

答案 0 :(得分:1)

您必须运行DBMS_JAVA.grant_permission包(详细信息应该在您的错误消息中,并且在某些情况下也会显示在数据库服务器文件系统上的跟踪文件中)。

以SYS和SQL接口连接:

begin
 dbms_java.grant_permission(........);
end;

答案 1 :(得分:1)

如果您拥有权限,我的预感是您需要将您的类放在java包中,或者小写类名称会使Solaris上的验证程序混淆(一个区分大小写的类,其中类名应该以一个大写字母开头)信)。

而不是

public class shai{

}

尝试使用包和有效的类名。

package com.company.Util
public class Shai{

}