Skip to Main Content

ORA-29532: Oracle Java stored procedure

UtsavJul 17 2014 — edited Jul 17 2014

I've compiled a java stored procedure in Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production.

But while call it through oracle function it is throwing excepion.

Java code, Oracle function and Exception is mentioned below.

Any clue to would be much appreciated as lead in resolving the issue.

import java.net.*;

public class CarService {

       public static String hitRestService() throws Exception{

              URL url = new URL("http://www.google.com/");

              URLConnection  conn = url.openConnection();

              if (conn instanceof HttpURLConnection) {

                     ((HttpURLConnection) conn).setRequestMethod("GET");

                     conn.connect();

                     String status;

                     int code = ((HttpURLConnection) conn).getResponseCode();

                     switch (code) {

                     case HttpURLConnection.HTTP_OK:

                           status="Pass";

                           break;

                     default:

                           status="Fail";

                           break;

                     }            

                     return "Status is "+status;

              }

              return "Status is Fail";

       }

};

create or replace FUNCTION FN_HIT_REST

RETURN VARCHAR2

AS LANGUAGE JAVA NAME 'CarService.hitRestService() return  java.lang.String';

ORA-29532: Java call terminated by uncaught Java exception: java.security.AccessControlException: the Permission (java.net.SocketPerm ission www.google.com:80 connect,resolve) has not been granted to My_Schema.

The PL/SQL to grant this is dbms_java.grant_permission( 'My_Schema','SYS:java.net.SocketPermission', 'www.google.com:80', 'connect,resolve' )

Regards,

Prashant

Comments
Post Details
Added on Jul 17 2014
2 comments
997 views