I have created a PL/SQL a Java Source, and privileges have been grante开发者_JAVA技巧d.
The PL/SQL procedure is executing and no error is coming up. Within the JavaSource there is the following unix command:
ls -al > /orion/list/list.txt
the file List.txt is not being created within the directory.
How would i know the problem if no errors are coming up? Could this be a problem of rights being given to oracle from unix.
Oracle is on unix sun solaris
From a distant memory, I am fairly certain you need to grant some privileges to the user executing the Java before it is allowed to execute unix commands.
Have a look at http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chten.htm
I think you need to give it java.io.FilePermission permission. One way to do this is to grant the role JAVASYSPRIV to your user. I have nowhere to test this out at the moment, but if that is not correct the link above should point you in the correct direction.
I concur with Stephen ODonnell.
I have implemented the exact same Java functionality (creating a file containing a directory listing) recently.
I needed to grant the following:
-- 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'
);
Hope this helps. Ollie.
精彩评论