oracle存储过程用过java 调用shell脚本问题 在线等
java代码:createorreplaceandcompilejavasourcenamedSH_RUNNBERasimportjava.io.IOException;...
java 代码:
create or replace and compile java source named SH_RUNNBER as
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class SH_RUNNBER {
public static void down_load_sftp(String shFile) throws Exception{
Process process;
process = Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",shFile},null,null);
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
process.waitFor();
while ((line = input.readLine()) != null){
System.out.println(line);
}
input.close();
}
}
oracle 存储过程:
procedure sftp_download_java(p_sh_file varchar2) as
language java name 'SH_RUNNBER.down_load_sftp(java.lang.String)';
procedure test_sftp;
sh 脚本:
#!/bin/bash
echo 1;
touch /home/oraprod/ftp/hahah.txt
echo 2;
权限赋值:
begin
-- 'DEV' 为 ORACLE 用户
dbms_java.grant_permission('DEV','java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete' );
dbms_java.grant_permission('DEV','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete' );
dbms_java.grant_permission('DEV', 'java.lang.RuntimePermission','*','writeFileDescriptor' );
commit;
end;
数据库oracle 11g,操作系统 aix
执行后,没有新建hahah.txt, 但我在数据库jdk 中单独执行java 是有效的
在线求高人指点 展开
create or replace and compile java source named SH_RUNNBER as
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class SH_RUNNBER {
public static void down_load_sftp(String shFile) throws Exception{
Process process;
process = Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",shFile},null,null);
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
process.waitFor();
while ((line = input.readLine()) != null){
System.out.println(line);
}
input.close();
}
}
oracle 存储过程:
procedure sftp_download_java(p_sh_file varchar2) as
language java name 'SH_RUNNBER.down_load_sftp(java.lang.String)';
procedure test_sftp;
sh 脚本:
#!/bin/bash
echo 1;
touch /home/oraprod/ftp/hahah.txt
echo 2;
权限赋值:
begin
-- 'DEV' 为 ORACLE 用户
dbms_java.grant_permission('DEV','java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete' );
dbms_java.grant_permission('DEV','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete' );
dbms_java.grant_permission('DEV', 'java.lang.RuntimePermission','*','writeFileDescriptor' );
commit;
end;
数据库oracle 11g,操作系统 aix
执行后,没有新建hahah.txt, 但我在数据库jdk 中单独执行java 是有效的
在线求高人指点 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询