Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Java Permissions Oracle 10 : updated

Re: Java Permissions Oracle 10 : updated

From: Stefan Knecht <knecht.stefan_at_gmail.com>
Date: Tue, 22 Aug 2006 12:32:36 +0200
Message-ID: <486b2b610608220332r24b4143fxd73bdabcd647d05b@mail.gmail.com>


Hi John,

check user_dump_dest for a tracefile whne the error occurs. You'll see the permission problem, along with the suggested dbms_java call to grant the permission.

Otherwise, call dbms_java.set_output(1000000) to redirect the output to the sql*plus console

Stefan

On 8/22/06, John Dunn <jdunn_at_sefas.com> wrote:
>
>
> > Can anyone please assist me with java permissions when running a java
> > function in Oracle 10 on linux?
> >
> > I use the following java code to run unix commands.
> >
> > It works fine provided the command does not write a file. However if the
> > command trys to write a file my code returns a return code of 127
> >
> > Is this a java permissions issue? There should be no linux file
> > pernmission issues as I can run the command Ok from the command line as
> > oracle
> >
> > What java permissions do I need to grant?
> >
> >
> > CREATE or REPLACE FUNCTION function_run_os_command(Command IN STRING)
> > RETURN NUMBER IS
> > LANGUAGE JAVA
> > NAME 'function_os_command.Run(java.lang.String) return integer';
> > /
> >
> > CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "function_os_command" AS
> > import java.io.*;
> > import java.util.*;
> > public class function_os_command
> > {
> > public static int Run(String Command)
> > {
> > int rc = 0;
> > try
> > {
> > Runtime rt = Runtime.getRuntime();
> > Process p = rt.exec(Command);
> > try {
> > rc = p.waitFor();
> > } catch (InterruptedException intexc) { rc = 2;}
> >
> > rt.gc();
> > } catch (Throwable t) { rc = 3; t.printStackTrace();}
> > return(rc);
> > }
> > }
> > /
> >
> > I use the following sqlplus to test it.
> >
> >
> > set serveroutput on
> > VARIABLE retcode NUMBER;
> > begin
> > -- This works
> > :retcode := function_run_os_command('/bin/sleep 10');
> > -- This return 127
> > :retcode := function_run_os_command('/bin/env > /tmp/envlog');
> > dbms_output.put_line('retcode = ' || :retcode);
> > end;
> >
> >
> >
> > John Dunn
> > Product Consultant
> > Direct Dial +44 (0) 117 373 6122
> > Sefas Innovation Ltd, CityPoint, Temple Gate, Bristol BS1 6PL, UK.
> > Tel: +44(0) 117 373 6114
> > Fax: +44 (0) 117 373 6115
> >
> > www.sefas.com
> >
> >
> >
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Aug 22 2006 - 05:32:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US