我试图通过执行过程
来执行位于数据库环境中的shell脚本CREATE OR REPLACE PROCEDURE RUNSS
AS LANGUAGE JAVA
NAME 'Command.run()';
运行一个使用ProcessBuilder
类
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class Command {
public static void run() throws IOException, InterruptedException {
String dir="/u01/app/temp";
ProcessBuilder pb = new ProcessBuilder("caller.sh");
pb.directory(new File(dir));
Process pr = pb.start();
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
pr.waitFor();
System.out.println("ok!");
in.close();
}
}
但当我执行以下程序时:
SET SERVEROUTPUT ON SIZE 10000;
EXEC DBMS_JAVA.SET_OUTPUT(10000);
EXECUTE RUNSS;
它给出错误:
execute runss
Error report -
ORA-29532: Java call terminated by uncaught Java exception: java.io.IOException: Cannot run program "caller.sh" (in directory "/u01/app/temp"): caller.sh not found (Note that lookup with PATH isn't done due to the oracle executable being setuid.)
ORA-06512: at "UCA.RUNSS", line 1
ORA-06512: at line 1
29532. 00000 - "Java call terminated by uncaught Java exception: %s"
*Cause: A Java exception or error was signaled and could not be
resolved by the Java code.
*Action: Modify Java code, if this behavior is not intended.
Exception in thread "Root Thread" java.io.IOException: Cannot run program "caller.sh" (in directory "/u01/app/temp"): caller.sh not found (Note that lookup with PATH isn't done due to the oracle executable being setuid.)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:495)
at Command.run(COMMAND:12)
Caused by: java.io.IOException: caller.sh not found (Note that lookup with PATH isn't done due to the oracle executable being setuid.)
at java.lang.OracleProcess.create(Native Method)
at java.lang.OracleProcess.construct(OracleProcess.java:112)
at java.lang.OracleProcess.<init>(OracleProcess.java:42)
at java.lang.OracleProcess.start(OracleProcess.java:383)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:488)
... 1 more