Advertisement

09.13.2007 at 06:18AM PDT, ID: 22826018
[x]
Attachment Details

Getting error while runing java stored procedure with jdbc odbc

Asked by Yogeshup in Oracle 9.x, Java Programming Language, Oracle HCM

Tags: , , ,

HI all,
        I am using oracle 9i at client side and oracle10g at server side on Microsoft platform. I have written two java class files on threading in which my thread class executes one stored procedure.
  I have tested this program from  console and its is running well.
  I have loaded this Java class file into oracle by  using loadjava utility with the valid status.
Now whenever i am trying to execute this Java files i am getting error which is related to some Java security policy.
  This is what i have done
CREATE OR REPLACE FUNCTION RunThread RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'Classname.Methodname() return java.lang.String';
/
  Function to execute Java class file.
I have used java jdbc odbc connectivity inside my java thread class
Here it is;

public class ProcessorThread implements Runnable{

    public static String checkFlag = "N";
      Connection conn;

    public ProcessorThread(){
      }                                                                                                                                 // Creates a new instance of ProcessorThread
   
    public void run() {
        try {
                        System.out.println("Connecting .........");
                        Class.forName("oracle.jdbc.driver.OracleDriver");      // Load oracle driver
                        String url = "jdbc:oracle:thin:@IP:sid";                    // Connection string
                        conn = DriverManager.getConnection(url,userid,pwd);  // Build connection
                        System.out.println("Executing procedure ........\n");
                        CallableStatement cstmt =(CallableStatement)conn.prepareCall("{call Sp_Demo}");
                        cstmt.execute();
                        this.checkFlag="Y";
                        Thread.sleep(0);
                        conn.close();

        }catch (SQLException sqle){
                        System.out.println("Problem creating connection: " + sqle);
                this.checkFlag="N";
            }catch (InterruptedException  iex){
                iex.printStackTrace();                                                                               // Can rollback from here if required, to release resources
                this.checkFlag="N";
        }catch (ClassNotFoundException cnfe){
                      System.err.println("Can't find driver: " + cnfe);
                      this.checkFlag="N";
                      System.exit(1);
            }
    }
}

Now while executing above Java class from oracle9i i am getting following error,
java.security.AccessControlException: the Permission (java.net.SocketPermission
ip:port connect,resolve) has not been granted to schema. The PL/SQL
to grant this is dbms_java.grant_permission( 'schema name',
'SYS:java.net.SocketPermission', 'ipaddress', 'connect,resolve' )
        at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:280
)
        at java.security.AccessController.checkPermission(AccessController.java:429)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:528)
        at
oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java
:192)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1030)
        at java.net.Socket.connect(Socket.java:446)
        at java.net.Socket.connect(Socket.java:402)
        at java.net.Socket.<init>(Socket.java:309)
        at java.net.Socket.<init>(Socket.java:124)
        at oracle.net.nt.TcpNTAdapter.connect(Unknown Source)
        at oracle.net.nt.ConnOption.connect(Unknown Source)
        at oracle.net.nt.ConnStrategy.execute(Unknown Source)
        at oracle.net.resolver.AddrResolution.resolveAndExecute(Unknown Source)
        at oracle.net.ns.NSProtocol.establishConnection(Unknown Source)
        at oracle.net.ns.NSProtocol.connect(Unknown Source)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1023)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:282)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:444)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:775)
        at java.sql.DriverManager.getConnection(DriverManager.java:573)
        at java.sql.DriverManager.getConnection(DriverManager.java:187)
        at LMSProcessorThread.run(LMSProcessorThread.java:28)

can any body tell me how to resolve this problem ????
   Any ideas are highly appreciated.


Start Free Trial
 
Loading Advertisement...
 
[+][-]09.13.2007 at 06:25AM PDT, ID: 19883398

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Oracle 9.x, Java Programming Language, Oracle HCM
Tags: java, procedure, stored, jdbc
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.13.2007 at 11:52PM PDT, ID: 19889440

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.31.2008 at 08:47AM PDT, ID: 21246430

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.10.2008 at 07:29PM PDT, ID: 22201501

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 08:04PM PDT, ID: 22275857

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 02:42PM PDT, ID: 22329492

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628