在写触发器调用shell脚本的时候总是报ORA-29531: no method executeShell in class JavaShellUtil1错误,网上的方法都试过了,不好使,试过用最简单的java类也是不行。同时在用call dbms_java.grant_permission('system','SYS:java.io.FilePermission','/home/oracle/tmp/*','execute');赋权的时候报ORA-29532: Java call terminated by uncaught Java exception: oracle.aurora.vm.IdNotFoundException:错误,实现的思路是:java程序调用shell,然后加载java类,存储过程调用java方法。求高手解决,感激不尽,代码如下:
java类代码
import java.io.BufferedReader;  
    import java.io.File;  
    import java.io.FileOutputStream;  
    import java.io.IOException;  
    import java.io.InputStreamReader;  
    import java.io.OutputStream;  
    import java.io.OutputStreamWriter;  
    import java.text.DateFormat;  
    import java.text.SimpleDateFormat;  
    import java.util.Date;  
      
    public class JavaShellUtil1 {  
    private static final String basePath = "";  
    private static final String executeShellLogFile = basePath + "executeShell.log";  
    private static final String shellCommand="sh ~/tmp/testshell.sh";
    public void executeShell() throws IOException {  
    StringBuffer stringBuffer = new StringBuffer();  
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS ");  
    try {  
    stringBuffer.append(dateFormat.format(new Date())).append("start shell").append(shellCommand).append(" \r\n");  
      
    Process pid = null;  
        String[] cmd = {"/bin/sh", "-c", shellCommand};  
    pid = Runtime.getRuntime().exec(cmd);
    if (pid != null) {  
    stringBuffer.append("pid:").append(pid.toString()).append("\r\n");  
    pid.waitFor();  
    } else {  
    stringBuffer.append("pid\r\n");  
    }  
    stringBuffer.append(dateFormat.format(new Date())).append("Shell over :\r\n");  
    } catch (Exception ioe) {  
    stringBuffer.append("run Error \r\n").append(ioe.getMessage()).append("\r\n");  
    } finally {  
    OutputStreamWriter outputStreamWriter = null;  
    try {  
    OutputStream outputStream = new FileOutputStream(executeShellLogFile);  
    outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8");  
    outputStreamWriter.write(stringBuffer.toString());  
    } catch (Exception e) {  
    e.printStackTrace();  
    } finally {  
    outputStreamWriter.close(); }  
    }  
    }
}
存储过程代码:
create or replace  procedure p_jsu
as language java name 'JavaShellUtil1.executeShell()';/
触发器代码:
create or replace trigger Main_trig
after insert on test
for each row 
begin
p_jsu;
end Main_trig;
/
shell脚本:
#!/bin/sh
#testshell.sh
echo `date` > test.log