oracle使用java source调用外部程序
3页1、ORACLE技术交流群(144243235)Oracle使用java source调用外部程序 需求 Oracle调用第三方外部程序。Oracle使用sqluldr2快速导出大批量数据,然后用winrar压缩后发送邮件。 本文档主要实现前两步需求,发送邮件程序这里不再说明。原码 授权begin dbms_java.grant_permission(SCOTT,SYS:java.io.FilePermission,read,write,execute,delete); end;begin dbms_java.grant_permission(SCOTT,java.lang.RuntimePermission,*,writeFileDescriptor ); end;java source create or replace and compile java source named jv_run_extpro asimport java.io.*;import java.lang.*;import java.util.*;import java.sql.*;import oracle.s
2、ql.*;public class jv_run_extpro public static void run(String cmd) throws IOException Process p=Runtime.getRuntime().exec(cmd); StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), Error); StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), Output); errorGobbler.start(); outputGobbler.start(); try p.waitFor(); catch(InterruptedException ie) System.out.println(ie); public static class StreamGobbler extends Thread InputStream is; String type; public StreamGobbler(Inpu
3、tStream is, String type) this.is = is; this.type = type; public void run() try InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while (line = br.readLine() != null) if (type.equals(Error) System.out.println(Error : + line); else System.out.println(Debug: + line); catch (IOException ioe) ioe.printStackTrace(); 说明:StreamGobbler这个类不能少,用于异步读取命令的输出。存储过程 create or replace procedure pro_jv_run_extpro(p_cmd varchar2) as language java name jv_run_extpro.run(java.lang.String); 调用 begin pro_jv_run_extpro(sqluldr264.exe scott/hhpdborcl query=select * from emp field=, head=yes file=D:Desktoptmpsqluldr2OUT2.TXT); pro_jv_run_extpro(D:Program FilesWinRARRar.exe a -ep -df D:Desktoptmpsqluldr220160916.rar D:Desktoptmpsqluldr2OUT2.TXT); end; 参数说明: a: 压缩文件-ep:包内不显示压缩路径-df:压缩后删除原文件总结 程序执行需要授权,如需要查看执行日志,可在sqlplus下先执行:Set serveroutput onExec dbms_java.set_output(5000);HH()总结整理
《oracle使用java source调用外部程序》由会员yi****st分享,可在线阅读,更多相关《oracle使用java source调用外部程序》请在金锄头文库上搜索。
公共关系教案公共关系协调
2016年度电控班《机械与电气识图》教案.docx
最新中职英语第二册教案:Unit404英语
新冠疫情安全教案
【海南部优】《刘姥姥进大观园》公开课教案
研究性学习教案_1644331326562
《运筹学》教案(6)—网络计划技术
最新中职药剂专业教案:药事法规与管理02
人教版生物选修3:2.1.2植物细胞工程的实际应用教案1
哈工大工程热力学教案第5章热力学第二定律
《电流与电压和电阻的关系》教案(1)
2017届一轮复习3.3连接体问题教案
最新中职英语第二册教案:Unit3IAmaVolunteer02英语
最新汽车使用性能与检测技术教案——第十一讲汽车的操纵稳定性.docx
生态系统的结构说课稿教案教学设计
1_丁大伟德育五分钟教案(1)
数控加工工艺与编程项目七教案.doc
家庭电路_教案2
工程力学教案圆轴扭转
《工程制图及CAD绘图》教案
2022-10-03 93页
2023-05-25 16页
2023-03-01 151页
2023-10-28 19页
2022-07-27 33页
2023-07-16 2页
2023-11-17 2页
2022-08-13 13页
2023-03-02 11页
2022-11-30 5页