援引:Doc ID 109095.1首先,在数据库端创建调用Unix shell的java类,用Runtime.getRuntime().exec()实现1.CREATE OR REPLACE JAVA SOURCE NAMED "CaptureStream" as
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();
}
}
};
/
Oracle中登陆时报ORA-28000: the account is locked-的错Oracle 等待事件相关资讯 Unix shell Stored Procedure
- UNIX shell获取IP和修改IP (08/07/2014 07:04:13)
- Unix Shell脚本编程知识点总结及范 (05/27/2013 13:13:34)
- HP UNIX shell得到5分钟前的时间 (03/30/2013 08:58:19)
| - Unix考古记:一个“遗失”的shell (06/08/2013 11:39:56)
- Linux/Unix shell 脚本监控磁盘可 (05/08/2013 06:19:39)
- Linux/Unix shell 自动发送AWR (03/10/2013 19:40:50)
|
本文评论 查看全部评论 (0)