驚呆,Oracle的這個(gè)坑竟然讓我踩上了
?
1 業(yè)務(wù)場(chǎng)景

id,a,b,c
1,a1,b1,c1
2,a2,b2,c2
3,a3,b3,c3
sqlldr?test/test123@biz?control=/home/jinjunzhu/biz/T_BIZ.ctl?log=/home/jinjunzhu/biz/T_BIZ.log?bad=/home/jinjunzhu/biz/T_BIZ.bad
options(skip=1,rows=10000,errors=0,parallel=true,bindsize=1048576,readsize=1048576)
load?data?
infile?'/home/jinjunzhu/biz/biz.csv'
fields?terminated?by?','
truncate?into?table?day_data
trailing?nullcols
(id,a,b,c)
private?int?execute(String?cmd)?throws?Exception{
????Process?process?=?Runtime.getRuntime().exec(new?String[]{"/bin/bash",?"-c",?cmd});
????process.waitFor(10,?TimeUnit.SECONDS);
????Integer?status?=?process.waitFor();
????return?status?==?null???-1?:?status;
}
?
2 問題現(xiàn)場(chǎng)
看不到有sqlldr命令等待的情況 CPU正常 手工執(zhí)行上面命令可以成功,但是打印的日志非常多,如下圖:

3 原因分析
3.1 Oracle版本低
3.2 數(shù)據(jù)落庫(kù)情況
3.3 最終答案
?
4 解決方案
4.1 增加參數(shù)
sqlldr?test/test123@biz?control=/home/jinjunzhu/biz/T_BIZ.ctl?log=/home/jinjunzhu/biz/T_BIZ.log?bad=/home/jinjunzhu/biz/T_BIZ.bad?silent=(ALL)
4.2 程序讀取標(biāo)準(zhǔn)輸出
private?int?execute(String?cmd)?throws?Exception{
????Process?process?=?Runtime.getRuntime().exec(new?String[]{"/bin/bash",?"-c",?cmd});
????process.waitFor(10,?TimeUnit.SECONDS);
????Integer?status;
????BufferedReader?br?=?new?BufferedReader(new?InputStreamReader(process.getInputStream()));
????String?line;
????while?((line?=?br.readLine())?!=?null)?{
????????System.out.println(line);
????}
????return?(status?=?process.waitFor())?==?null???-1?:?status;
}
4.3 文件接收標(biāo)準(zhǔn)輸出
sqlldr?test/test123@biz?control=/home/jinjunzhu/biz/T_BIZ.ctl?log=/home/jinjunzhu/biz/T_BIZ.log?bad=/home/jinjunzhu/biz/T_BIZ.bad?1>/home/jinjunzhu/biz/std.log?2>/home/jinjunzhu/biz/err.log
?
5 總結(jié)
有道無術(shù),術(shù)可成;有術(shù)無道,止于術(shù)
歡迎大家關(guān)注Java之道公眾號(hào)
好文章,我在看??
