2011-08-22 104 views
2

我已經創建了PL/SQL Java源代碼,並且授予了特權。通過Oracle的Unix命令

PL/SQL過程正在執行,沒有錯誤出現。 內的JavaSource有下列unix命令:

LS -al> /orion/list/list.txt

不被該目錄中創建的文件LIST.TXT。

如果沒有錯誤出現,我會如何知道問題? 這可能是一個問題,從UNIX的權利給甲骨文。

甲骨文是在UNIX Sun Solaris的

+0

你見過這個問湯姆線程? http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3069633370832 –

+0

Oracle服務器上可能有一個跟蹤文件,它會提供更多信息。 –

回答

2

我同意Stephen ODonnell。

最近我實現了完全相同的Java功能(創建包含目錄列表的文件)。

我需要授予以下:

-- this grants read privilege on STDIN 
EXEC dbms_java.grant_permission(
    grantee => '<username>', 
    permission_type => 'SYS:java.lang.RuntimePermission', 
    permission_name => 'readFileDescriptor', 
    permission_action => null 
); 

-- this grants write permission on STDOUT 
EXEC dbms_java.grant_permission(
    grantee => '<username>', 
    permission_type => 'SYS:java.lang.RuntimePermission', 
    permission_name => 'writeFileDescriptor', 
    permission_action => null 
); 

-- this grants execute privilege for the 'ls' command 
EXEC dbms_java.grant_permission(
    grantee => '<username>', 
    permission_type => 'SYS:java.io.FilePermission', 
    permission_name => '/bin/ls', 
    permission_action => 'execute' 
); 

-- this grants read, write, delete and execute on all 
-- of the referenced directories (subdirectories of <directory>) 
EXEC dbms_java.grant_permission(
    grantee => '<username>', 
    permission_type => 'SYS:java.io.FilePermission', 
    permission_name => '<directory>/-', 
    permission_action => 'read,write,delete,execute' 
); 

-- this grants execute on sh 
EXEC dbms_java.grant_permission(
    grantee => '<username>', 
    permission_type => 'SYS:java.io.FilePermission', 
    permission_name => '/bin/sh', 
    permission_action => 'read,execute' 
); 

希望這有助於。 Ollie。

+0

是的,該代碼看起來很熟悉 - 可能最好是運行它,或者依賴於我建議的ROLE,只是發揮作用並不能提供所有需要的東西。 –

+1

我已設置以下權限,但問題仍然存在。這可能是由於Oracle用戶與Unix用戶不是相同的,因爲DBMS_JAVA.grant_permission('ORION','java.io.FilePermission','TestHostCommand','讀取,寫入,執行,刪除')會啓動DBMS_JAVA.grant_permission(012)。結束;開始DBMS_JAVA.grant_permission('ORION','SYS:java.lang.RuntimePermission','writeFileDescriptor','');結束;開始DBMS_JAVA.grant_permission('ORION','SYS:java.lang.RuntimePermission','readFileDescriptor','');結束; – CRL88

+0

「這可能是由於Oracle用戶與Unix用戶不一樣嗎?」。不,數據庫中的用戶與訪問OS命令的數據庫分離。 Oracle是否擁有OS目錄的訪問權限? – Ollie

3

從一個遙遠的記憶,我相當肯定,你需要授予一些特權來執行的Java允許執行的UNIX命令之前,它的用戶。

看一看http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chten.htm

我認爲你需要給它java.io.FilePermission中的權限。一種方法是將JAVASYSPRIV授予用戶。目前我無處可以測試,但如果不正確,上面的鏈接應該指向正確的方向。

+0

權限已被DBA授予 問題是在我的Sql Navigator中沒有記錄任何錯誤,但目錄 – CRL88

+0

中沒有創建文件list.txt請求您的DBA查看警報日誌以查看是否Oracle正在報告任何問題。 – Ollie