begin
Dbms_Java.Grant_Permission('PSIID','java.io.FilePermission', '<<ALL FILE>>','read ,write, execute, delete')
Dbms_java.grant_permission('PSIID', 'SYS:java.io.FilePermission', '<<ALL FILES>>','read ,write, execute, delete')
Dbms_Java.Grant_Permission('PSIID', 'java.io.FilePermission', 'd:a.bat','read ,write, execute, delete')
dbms_java.grant_permission('PSIID', 'java.lang.RuntimePermission','*','writeFileDescriptor' )
end
2、登陆psiid用户创建java程序资源
create or replace and compile
java source named "Util"
as
import java.io.*
import java.lang.*
public class Util extends Object
{
public static int RunThis(String args)
{
Runtime rt = Runtime.getRuntime()
int rc = -1
try
{
Process p = rt.exec(args)
int bufSize = 4096
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize)
int len
byte buffer[] = new byte[bufSize]
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len)
rc = p.waitFor()
}
catch (Exception e)
{
e.printStackTrace()
rc = -1
}
finally
{
return rc
}
}
}
3、创建调用Java资源的函数
create or replace function RUN_CMD(p_cmd in varchar2) return number
as
language java name 'Util.RunThis(java.lang.String) return integer'
4、建立一过程调用存储过程
create or replace procedure RUN(p_cmd in varchar2)
as
x number
begin
x := run_cmd(p_cmd)
end
------------------------------
------- 执行例子
------------------------------
--d:a.bat 文件
cd d:
rename %1 %2
SQL>exec rc('d:a.bat mytest.sql b.sql')
D:oracleora92DATABASE>cd d:
D:>rename mytest.sql b.sql
exec :x := RUN_CMD('ipconfig')
variable x number
exec dbms_java.set_output(100000)
exec :x := RUN_CMD('ipconfig')
exec :x := RUN_CMD('d:a.bat')
1.可以用离线查询,就是先把数据都取出来,再用list *** 作。2.实时查询,每次查询5条记录,即第一条,下一条,当前记录,前一条,最后一条。这样就有了每条记录的id号,再提交按钮的是后直接用java查询,重复即可。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)