Demand
Oracle invokes third party external programs. Oracle uses SQLULDR2 to quickly export large amounts of data and then send messages with WinRAR compression.
Source
Java source
Create or replace and compile Java source named Jv_run_extpro as import java.io.*;
Import java.lang.*;
Import java.util.*;
Import java.sql.*;
Import oracle.sql.*; Publicclass Jv_run_extpro {publicstaticvoid 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);
} publicstaticclass Streamgobbler extends Thread {InputStream is;
String type;
Public Streamgobbler (InputStream are, String type) {this.is = is;
This.type = type;
Publicvoid 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);
A catch (IOException IoE) {ioe.printstacktrace ();
}
}
}
}
Stored Procedures
Create or Replace procedure Pro_jv_run_extpro (P_cmd varchar2) as
Language Java name ' Jv_run_extpro.run (java.lang.String) ';
Call
Begin
Pro_jv_run_extpro (' Sqluldr264.exe scott/hh@pdborcl query= "SELECT * from emp" field=, Head=yes file=d:\ Desktop\tmp\sqluldr2\out2. TXT ');
Pro_jv_run_extpro (' "D:\Program files\winrar\rar.exe" a-ep-df "D:\Desktop\tmp\sqluldr2\20160916.rar" "D:\Desktop\ Tmp\sqluldr2\out2. TXT "');
End
Summarize
Java Source Streamgobbler This class cannot be used to read the output of commands asynchronously.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.