Hello,
I have written a java stored procedure to execute an exe file, which works fine when compiled.The class code is given below.
create or replace and resolve java source named "CommandExection"
as
import java.io.*;
import java.util.*;
public class CommandExection1 {
public static void Command(String commandline) {
try {
String line;
Process p = Runtime.getRuntime().exec(commandline);
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
}
}
/
Through a stored procedure i am acessing the class which is given below,
create or replace procedure Exe_cmd(path in varchar2)
as
language java
name 'CommandExection1.Command(path)';
I am able to create stored procedure sucessfully.And i have set permissions to execute procedure as shown below
SQL> declare
2 SCHEMA varchar2(30) := 'SYSTEM';
3 begin
4 dbms_java.grant_permission(
5 SCHEMA,
6 'SYS:java.io.FilePermission',
7 '<<ALL FILES>>',
8 'execute'
9 );
10
11 dbms_java.grant_permission(
12 SCHEMA,
13 'SYS:java.lang.RuntimePermission',
14 'writeFileDescriptor',
15 '*'
16 );
17
18 dbms_java.grant_permission(
19 SCHEMA,
20 'SYS:java.lang.RuntimePermission',
21 'readFileDescriptor',
22 '*'
23 );
24
25 commit;
26 end;
27 /
PL/SQL procedure successfully completed.
I am able to execute it but not able to see my output its just showing as below
SQL> exec Exe_cmd('D:\\exeapp.exe');
PL/SQL procedure successfully completed.
if i use
set serverout on size 1000000
exec dbms_java.set_output(1000000)
then execute my procedure i amgetting the following
SQL> exec Exe_cmd('D:/exeapp.exe');
java.io.IOException: The handle is invalid.
at oracle.aurora.java.lang.OracleProcess.create(Nativ e Method)
at oracle.aurora.java.lang.OracleProcess.construct(Or acleProcess.java:25)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at Trial.Try(Trial:12)
PL/SQL procedure successfully completed.
I couldnt find the output of my exe file which opens up a ASP.net Window Form.
From three days I am trying so many things to achieve this but i am not able to do.
Please help me.