2009-06-17 82 views
2

我有一個簡單的java類來計算SHA1,我想從Oracle的PLSQL過程中使用它。 以下建議來自: SHA1, SHA256, SHA512 in Oracle for free without using DBMS_CRYPTO (我的簡單的情況下使用unly SHA1,不需要任何廣口瓶,並且由該進口java.security java.io和僅sha1.class的)如何在Solaris上的Oracle上安裝Java類

我編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?

+0

您是否嘗試以普通用戶或具有DBA特權的用戶身份加載它? – 2009-06-29 11:17:07

回答

1

您必須運行DBMS_JAVA.grant_permission包(詳細信息應在您的錯誤消息中,並且在某些情況下也顯示在數據庫服務器文件系統的跟蹤文件中)。

連接爲SYS和從SQL接口:

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

如果您擁有的權限,我的直覺是,你要麼需要在您的類的java包或小寫類名混淆在Solaris上驗證器(類名稱應以大寫字母開頭的區分大小寫的環境)。

而不是

public class shai{ 

} 

用包和有效的類名稱試試吧。

package com.company.Util 
public class Shai{ 

} 
+0

我在Linux上也嘗試過它,它工作。我也嘗試使用.java源代碼:在Linux上工作,但在Solaris上失敗。 – 2009-06-29 10:30:40