Reference: Doc ID 109095.1
First, create a Java class that calls Unix shellon the database, and use runtime.getruntime(cmd.exe c () to implement
1.
Create or replace java source named "CaptureStream"
Import java. util .*;
Import java. io .*;
Class CaptureStream implements Runnable {
Private final InputStream is;
Private final String type;
Private final OutputStream redirect;
Private boolean redirected = false;
CaptureStream (InputStream is, String type, OutputStream redirect)
{
This. is = is;
This. type = type + "> ";
This. redirect = redirect;
}
CaptureStream (InputStream is, String type)
{
This (is, type, null );
}
CaptureStream (InputStream is)
{
This (is, "", null );
}
Public void run ()
{
Try {
PrintWriter pw = null;
If (redirect! = Null ){
Pw = new PrintWriter (redirect );
Redirected = true;
}
InputStreamReader isr = new InputStreamReader (is );
BufferedReader br = new BufferedReader (isr );
String line = null;
While (line = br. readLine ())! = Null ){
System. out. println (type + line );
If (redirected ){
Pw. println (line );
}
}
If (redirected ){
Pw. flush ();
Pw. close ();
}
Br. close ();
Isr. close ();
} Catch (IOException ioe ){
Ioe. printStackTrace ();
}
}
};
/