Forum Stats

  • 3,752,166 Users
  • 2,250,466 Discussions
  • 7,867,743 Comments

Discussions

Java stored procedure in oracle

669410
669410 Member Posts: 32
edited Dec 1, 2008 1:49AM in SQL & PL/SQL
Hi,
This is regarding the java stored procedure.
I have written a java stored procedure for mailing from DB.But it required some grants or extra privileges to be run from the data base.
CAn anyone please specify what are the grants needed for this.

I have to give to following permissions to the java methods....

dbms_java.grant_permission(user,'java.util.PropertyPermission','*','read');
dbms_java.grant_permission(user,'java.net.SocketPermission','*','connect, resolve');
dbms_java.grant_permission(user,'java.io.FilePermission',FilePathName,'read');


Can anyone please specify what are the privileges required to run the above.Because I have tired it with normal priviledges..it's not working.....

I am getting the following error while executing this from the normal user..rather the user that have been created for me....

ORA-29532: Java call terminated by uncaught Java exception: java.lang.SecurityException: policy table update SYS:java.util.PropertyPermission, *
ORA-06512: at "SYS.DBMS_JAVA", line 313
ORA-06512: at line 1



Thanks,
Anirban Datta

Edited by: user5815929 on Nov 30, 2008 8:42 PM

Best Answer

  • zhxiangxie
    zhxiangxie Member Posts: 203
    Accepted Answer
    Hi Anirban,

    You can run those command in SQL*PLUS or command window of PL/SQL Developer.

    exec dbms_java.grant_permission(user,'java.util.PropertyPermission','*','read');
    exec dbms_java.grant_permission(user,'java.net.SocketPermission','*','connect, resolve');
    exec dbms_java.grant_permission(user,'java.io.FilePermission',FilePathName,'read');

    If you do not have enough privilege to do these, you may try to use account system or sys.

    Best regards,
    Zhxiang

Answers

  • OrionNet
    OrionNet Member Posts: 4,542
    Hope this link helps resolving your issue

    http://www.dba-oracle.com/t_ora_29532_java_call_terminated_by_uncaught_java_exception_string.htm
    OrionNet
  • 669410
    669410 Member Posts: 32
    HI,
    Thanks..but the site is not opeing...is it opening at yor end.....??can u please post here from the site....hope I am not asking a lot of favour....

    Thanks again..
    Anirban Datta....
  • OrionNet
    OrionNet Member Posts: 4,542
    The Oracle docs note this on the ora-29532 error:

    ORA-29532: Java call terminated by uncaught Java exception: string

    Cause: A Java exception or error was signaled and could not be resolved by the Java code.

    Action: Modify Java code, if this behavior is not intended.
    Oracle MetaLink Documents offer descriptions of problems regarding ORA-29532. They outline these error possibilities and resolutions by showing three examples. Perhaps one of these examples is similar to your problem with ORA-29532:

    Sometimes an application running in the Oracle JVM
    will fail with a java permissions error having the
    following format:

    (Note: Message shown below have been reformatted for easier readability.)

    java.sql.SQLException: ORA-29532:Java call terminated by uncaught Java exception:

    followed by a detailed error message similar to one of the following messages:

    -----------
    Example # 1
    -----------

    java.security.AccessControlException: the Permission

    (java.net.SocketPermission hostname resolve)

    has not been granted by dbms_java.grant_permission to

    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))

    -----------
    Example # 2
    -----------

    java.security.AccessControlException: the Permission

    (java.util.PropertyPermission * read,write)

    has not been granted by dbms_java.grant_permission to

    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))


    -----------
    Example # 3
    -----------

    java.security.AccessControlException: the Permission

    (java.io.FilePermission \matt1.gif read)

    has not been granted by dbms_java.grant_permission to

    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))


    The reason ORA-29532 occurs is because "The java 2 permission stated in line # 2 of each of the above "Examples"
    has not been granted to the user specified in line 4 of the above "Examples"." To resolve ORA-29532:

    The methodology to solve this issue is identical for all java 2 permissions
    cases.

    1) Format a call "dbms_java.grant_permission" procedure as described below.
    2) Logon as SYS or SYSTEM
    3) Issue the TWO commands shown below
    4) Logoff as SYS or SYSTEM
    5) Retry your application

    ---------------
    For Example # 1
    ---------------

    1) Logon as SYS or SYSTEM
    2) Issue the following commands :

    a) call dbms_java.grant_permission('SCOTT',
    'java.net.SocketPermission',
    'hostname',
    'resolve');
    b) commit;

    Note: Commit is mandatory !!

    3) Logoff as SYS or SYSTEM

    4) Retry your application

    ---------------
    For Example # 2
    ---------------

    1) Logon as SYS or SYSTEM
    2) Issue the following commands :

    a) call dbms_java.grant_permission('SCOTT',
    'java.util.PropertyPermission',
    '*',
    'read,write');
    b) commit;

    Note: Commit is mandatory !!

    3) Logoff as SYS or SYSTEM

    4) Retry your application

    ---------------
    For Example # 3
    ---------------

    1) Logon as SYS or SYSTEM
    2) Issue the following commands :

    a) call dbms_java.grant_permission('SCOTT',
    'java.io.FilePermission',
    '\matt1.gif',
    'read');
    b) commit;

    Note: Commit is mandatory !!

    3) Logoff as SYS or SYSTEM

    4) Retry your application
    OrionNet
  • zhxiangxie
    zhxiangxie Member Posts: 203
    Accepted Answer
    Hi Anirban,

    You can run those command in SQL*PLUS or command window of PL/SQL Developer.

    exec dbms_java.grant_permission(user,'java.util.PropertyPermission','*','read');
    exec dbms_java.grant_permission(user,'java.net.SocketPermission','*','connect, resolve');
    exec dbms_java.grant_permission(user,'java.io.FilePermission',FilePathName,'read');

    If you do not have enough privilege to do these, you may try to use account system or sys.

    Best regards,
    Zhxiang
This discussion has been closed.