run exe from oracle trigger.
591089Aug 13 2007 — edited Aug 13 2007Hi! i want to run an exe from oracle trigger. Since it's not possible to run an exe directly from a trigger i'm using java stored procedure to run an exe. I am able to run an exe from java source file in java compiler, but if I use the same class file in oracle procedure the exe file is not running. the code i am using is:
import java.io.*;
import java.util.*;
public class MyCommands1 {
public static void Command()
{
try {
String line;
Process p = Runtime.getRuntime().exec("Calc.exe");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
}
catch (Exception err)
{
err.printStackTrace();
}
}
public static void main(String args[])
{
MyCommands1 x=new MyCommands1();
x.Command();
}
}
This works perfectly in java compiler and runs the windows calculator. I want the same functionality from oracle. I've written a java source file ,
create or replace and compile Java Source named "MyCommands1" as
import java.io.*;
import java.util.*;
public class MyCommands1 {
public static void Command()
{
try {
String line;
Process p = Runtime.getRuntime().exec("Calc.exe");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
}
catch (Exception err)
{
err.printStackTrace();
}
}
public static void main(String args[])
{
MyCommands1 x=new MyCommands1();
x.Command();
}
}
/
java created successfully.
Then writtena procedure,
create or replace procedure Execc
as
language JAVA
name 'MyCommands1.Command()';
/
procedure created successfully. but it's not running the exe.
I get the errors,
java.io.IOException: The handle is invalid.
at oracle.aurora.java.lang.OracleProcess.create(Native Method)
at oracle.aurora.java.lang.OracleProcess.construct(OracleProcess.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 OSCmd.Commands(OSCmd:12)
after i do.
set serverout on size 100000
exec dbms_java.set_output(1000000);
Please somebody help me with this.
I am posting the same question for the second time.
Last time you asked me to go for dbms scheduler, but it doesn't work for me.
for that i can directly use windows scheduler.
Please tell me. Is it possible to run an exe from an oracle procedure?
And use that procedure in oracle trigger.
Thanks.