descriptor not valid [message #325469] |
Fri, 06 June 2008 05:06 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
I use Oracle 9i database on Win XP.
in order to call a shel cmd from PLSQL, I've resumed the folling STEPS:
STEP 1: Create an OSCommand Java Class ( ==> Successfully )
STEP 2: Create a Wrapper Function ( ==> Successfully )
STEP 3: I run the pack dbms_java to grant necessary privs to user SYS ( ==> Successfully )
STEP 4: connect to sqlplus using SYS user and run the code bellow :
SQL> Declare
2 x Varchar2(2000);
3 Begin
4 x := OSCommand_Run('dir c:\a*.*');
5 DBMS_OUTPUT.Put_Line(x);
6 End;
7 /
Descripteur non valide
PL/SQL procedure successfully completed.
SQL>
QUESTION:
=========
I'm upset, because I don't have the list of files and directories existing in my hard drive C:\.
I don't know how to change and correct the "listener.ora" and "tnsnames.ora" !
What have I missed ? why does not this work ?
.. Thankful for any help.
|
|
|
|
Re: descriptor not valid [message #325536 is a reply to message #325487] |
Fri, 06 June 2008 09:21 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
Quote:
connect to sqlplus using SYS user
STEP 4:
D:\scripts>
D:\scripts>sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Ve Jun 6 15:20:05 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL>
|
|
|
Re: descriptor not valid [message #325538 is a reply to message #325469] |
Fri, 06 June 2008 09:28 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
STEP 5:
SQL> show echo
echo OFF
SQL> set echo on
SQL> @java\test
SQL> Set Serverout On
SQL> set termout on
SQL>
SQL> Declare
2 x Varchar2(2000);
3 Begin
4 x := OSCommand_Run('dir c:\a*.*');
5 DBMS_OUTPUT.Put_Line(x);
6 End;
7 /
Descripteur non valide
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL>
|
|
|
|
Re: descriptor not valid [message #325570 is a reply to message #325562] |
Fri, 06 June 2008 10:32 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
I use Oracle 9i2010 database on Win XP.
in order to call a shel cmd from PLSQL, I've resumed the folling STEPS:
STEP 1: Create an OSCommand Java Class. See code below:
SQL> -- Create the OSCommand Java Class using the following statement:
SQL>
SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS import java.io.*;
2 public class OSCommand
3 {
4 public static String Run(String Command)
5 {
6 try
7 {
8 Runtime.getRuntime().exec(Command);
9 return("0");
10 }
11 catch (Exception e)
12 {
13 System.out.println("Error running command: " + Command +
14 "\n" + e.getMessage());
15 return(e.getMessage());
16 }
17 }
18 }
19 /
Java crÚÚ.
SQL>
|
|
|
|
Re: descriptor not valid [message #325572 is a reply to message #325570] |
Fri, 06 June 2008 10:34 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
STEP 2: Create a Wrapper Function. See code below:
SQL> -- Create the following Wrapper Function using the following statement:
SQL>
SQL> CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
2 RETURN VARCHAR2 IS
3 LANGUAGE JAVA
4 NAME 'OSCommand.Run(java.lang.String) return int';
5 /
Fonction crÚÚe.
SQL>
SQL>
|
|
|
Re: descriptor not valid [message #325574 is a reply to message #325469] |
Fri, 06 June 2008 10:36 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
STEP 3: I run the pack dbms_java to grant necessary privs to user SYS .
See below:
SQL> -- Grant permission to SYS to be able to use java proc created
SQL>
SQL> Execute dbms_java.grant_permission( 'SYS', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute');
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL> execute dbms_java.grant_permission( 'SYS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '*' );
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL> execute dbms_java.grant_permission( 'SYS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '*' );
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL> Commit;
Validation effectuÚe.
SQL>
SQL>
|
|
|
Re: descriptor not valid [message #325575 is a reply to message #325469] |
Fri, 06 June 2008 10:37 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
STEP 4:
SQL>
SQL> conn / as sysdba
ConnectÚ.
SQL>
SQL> Set Serverout On
SQL> set termout on
SQL>
SQL> Declare
2 x Varchar2(2000);
3 Begin
4 x := OSCommand_Run('dir c:\a*.*');
5 DBMS_OUTPUT.Put_Line(x);
6 End;
7 /
Descripteur non valide
ProcÚdure PL/SQL terminÚe avec succÞs.
SQL>
SQL>
|
|
|
Re: descriptor not valid [message #325576 is a reply to message #325469] |
Fri, 06 June 2008 10:38 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
QUESTION:
=========
I'm upset, because I don't have the list of files and directories existing in my hard drive C:\.
I don't know how to change and correct the "listener.ora" and "tnsnames.ora" !
What have I missed ? why does not this work ?
.. Thankful for any help.
|
|
|
|
|
Re: descriptor not valid [message #325583 is a reply to message #325577] |
Fri, 06 June 2008 10:52 |
amrlekid
Messages: 18 Registered: May 2008
|
Junior Member |
|
|
I meant the following:
May be I should modify "Listener.ora" OR "tnsnames.ora"!!
.. Still I don't know exactly what new statements should be implemented in these 2 files!
..Anyway .
What Solution do you suggest to solve this problem?
Thanks.
|
|
|
|
|