Thursday, May 8, 2008

Java in Oracle, you need permissions!!!

One of the interesting things when you work with Java in Oracle is permissions, or better the lack of error messages telling you what permissions you need. If you have any IO actions in your Java code, you will need to give the user special permissions to do so. Oracle has one of their libraries dedicated to this need. It is called DBMS_JAVA.

-- To give permissions to execute IO operations
BEGIN
DBMS_JAVA.grant_permission('ODS_ETL', 'java.io.FilePermission', 'C:\TEMP\20070908A\', 'read ,write, execute, delete');
END;

-- To remove permissions to execute IO operations

BEGIN
DBMS_JAVA.revoke_permission('ODS_ETL', 'java.io.FilePermission', 'C:\TEMP\20070908A\', 'read ,write, execute, delete');
END;


--to get a list of your java permissions
SELECT * FROM USER_JAVA_POLICY

No comments: