Path: news.cambrium.nl!textnews.cambrium.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!feeder.news-service.com!postnews.google.com!32g2000yqj.googlegroups.com!not-for-mail
From: ddf <oratune@msn.com>
Newsgroups: comp.databases.oracle.misc
Subject: Re: JAVA file permissions
Date: Tue, 7 Jul 2009 08:24:21 -0700 (PDT)
Organization: http://groups.google.com
Lines: 150
Message-ID: <73489ffa-e698-44b8-a61b-a12a34024541@32g2000yqj.googlegroups.com>
References: <facc3fd1-3df9-4c55-a520-150294252641@d36g2000prb.googlegroups.com>
NNTP-Posting-Host: 138.32.32.166
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1246980261 16144 127.0.0.1 (7 Jul 2009 15:24:21 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 7 Jul 2009 15:24:21 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 32g2000yqj.googlegroups.com; posting-host=138.32.32.166; 
 posting-account=KXUmygkAAABvBFmgDBe4RBLFwhTRAMZC
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ;  Embedded Web 
 Browser from: http://bsalsa.com/; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET 
 CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
Xref:  news.cambrium.nl

On Jul 7, 10:07=A0am, CenturionX <darwinbaldr...@gmail.com> wrote:
> Hello,
>
> I'm working with ORACLE 10.2.0.4.0 on windows server 2003 R2.
>
> I need to execute a DOS batch file. =A0I used some code i found in the
> web (see the code below).
>
> When i try to give permission to execut ethe file:
> =A0 =A0EXEC DBMS_JAVA.grant_permission('CMS',
> 'SYS.java.io.FilePermission', 'K:\Mesr\DBP_EXEC_FROM_ORA\',
> 'read ,write, execute');
>
> I get this error:
>
> ORA-29532: Java call terminated by uncaught Java exception:
> java.lang.ClassNotFoundException: sys/java/io/filepermission
> ORA-06512: at "SYS.DBMS_JAVA", line 313
> ORA-06512: at line 1
>
> Somebody has a good idea on this.
>
> THANKS.
>
> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
> import java.io.*;
> public class Host {
> =A0 public static void executeCommand(String command) {
> =A0 =A0 try {
> =A0 =A0 =A0 String[] finalCommand;
> =A0 =A0 =A0 if (isWindows()) {
> =A0 =A0 =A0 =A0 finalCommand =3D new String[4];
> =A0 =A0 =A0 =A0 // Use the appropriate path for your windows version.
> =A0 =A0 =A0 =A0 finalCommand[0] =3D "C:\\windows\\system32\\cmd.exe"; =A0=
//
> Windows XP/2003
> =A0 =A0 =A0 =A0 //finalCommand[0] =3D "C:\\winnt\\system32\\cmd.exe"; =A0=
//
> Windows NT/2000
> =A0 =A0 =A0 =A0 finalCommand[1] =3D "/y";
> =A0 =A0 =A0 =A0 finalCommand[2] =3D "/c";
> =A0 =A0 =A0 =A0 finalCommand[3] =3D command;
> =A0 =A0 =A0 }
> =A0 =A0 =A0 else {
> =A0 =A0 =A0 =A0 finalCommand =3D new String[3];
> =A0 =A0 =A0 =A0 finalCommand[0] =3D "/bin/sh";
> =A0 =A0 =A0 =A0 finalCommand[1] =3D "-c";
> =A0 =A0 =A0 =A0 finalCommand[2] =3D command;
> =A0 =A0 =A0 }
>
> =A0 =A0 =A0 final Process pr =3D Runtime.getRuntime().exec(finalCommand);
> =A0 =A0 =A0 pr.waitFor();
>
> =A0 =A0 =A0 new Thread(new Runnable(){
> =A0 =A0 =A0 =A0 public void run() {
> =A0 =A0 =A0 =A0 =A0 BufferedReader br_in =3D null;
> =A0 =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 br_in =3D new BufferedReader(new InputStreamReade=
r
> (pr.getInputStream()));
> =A0 =A0 =A0 =A0 =A0 =A0 String buff =3D null;
> =A0 =A0 =A0 =A0 =A0 =A0 while ((buff =3D br_in.readLine()) !=3D null) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println("Process out :" + buff);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 try {Thread.sleep(100); } catch(Exception e) =
{}
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 br_in.close();
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 catch (IOException ioe) {
> =A0 =A0 =A0 =A0 =A0 =A0 System.out.println("Exception caught printing pro=
cess
> output.");
> =A0 =A0 =A0 =A0 =A0 =A0 ioe.printStackTrace();
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 finally {
> =A0 =A0 =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 br_in.close();
> =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception ex) {}
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 }).start();
>
> =A0 =A0 =A0 new Thread(new Runnable(){
> =A0 =A0 =A0 =A0 public void run() {
> =A0 =A0 =A0 =A0 =A0 BufferedReader br_err =3D null;
> =A0 =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 br_err =3D new BufferedReader(new InputStreamRead=
er
> (pr.getErrorStream()));
> =A0 =A0 =A0 =A0 =A0 =A0 String buff =3D null;
> =A0 =A0 =A0 =A0 =A0 =A0 while ((buff =3D br_err.readLine()) !=3D null) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println("Process err :" + buff);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 try {Thread.sleep(100); } catch(Exception e) =
{}
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 br_err.close();
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 catch (IOException ioe) {
> =A0 =A0 =A0 =A0 =A0 =A0 System.out.println("Exception caught printing pro=
cess
> error.");
> =A0 =A0 =A0 =A0 =A0 =A0 ioe.printStackTrace();
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 finally {
> =A0 =A0 =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 br_err.close();
> =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception ex) {}
> =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 }).start();
> =A0 =A0 }
> =A0 =A0 catch (Exception ex) {
> =A0 =A0 =A0 System.out.println(ex.getLocalizedMessage());
> =A0 =A0 }
> =A0 }
>
> =A0 public static boolean isWindows() {
> =A0 =A0 if (System.getProperty("os.name").toLowerCase().indexOf
> ("windows") !=3D -1)
> =A0 =A0 =A0 return true;
> =A0 =A0 else
> =A0 =A0 =A0 return false;
> =A0 }
>
> };
>
> /
> show errors java source "Host"
>
> CREATE OR REPLACE PROCEDURE host_command (p_command =A0IN =A0VARCHAR2)
> AS LANGUAGE JAVA
> NAME 'Host.executeCommand (java.lang.String)';
> /
> show errors
>
> EXEC DBMS_JAVA.grant_permission('CMS', 'SYS.java.io.FilePermission',
> 'K:\Mesr\DBP_EXEC_FROM_ORA\', 'read ,write, execute');
> EXEC Dbms_Java.Grant_Permission('CMS',
> 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
> EXEC Dbms_Java.Grant_Permission('CMS',
> 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');

Normally the \ is an escape character; have you given thought to
possibly changing the string to this:

EXEC DBMS_JAVA.grant_permission('CMS', 'SYS.java.io.FilePermission',
'K:\\Mesr\\DBP_EXEC_FROM_ORA\\', 'read ,write, execute');


David Fitzjarrell
