java调用外部命令 关于sqlloader 急
命令行 sqlldr test/test@test control=a.ctl log=ok.log bad=bad.log,
直接在cmd下执行没有问题,但是通过java的 Runtime.getRuntime().exec("sqlldr test/test@KEN control=E:/aaaa/a.ctl log=E:/aaaa/ok.log bad=E:/aaaa/bad.log");却报错,Exception in thread "main"
java.io.IOException: Cannot run program "sqlldr": CreateProcess error=2,哪位朋友碰到过的,指点下
------解决方案--------------------安装Oracle Client了吗?光有服务器?
------解决方案--------------------String cmd="D:/oracle/ora92/bin/sqlldr userid=test/test@testdb skip=1 control=e:/test.ctl bad=e:/bad.txt";
try
{
Process ldr=Runtime.getRuntime().exec(cmd);
InputStream stderr = ldr.getInputStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
System.out.println("*** " + line);
stderr.close();
isr.close();
br.close();
try
{
ldr.waitFor();
}
catch(Exception e)
{
System.out.println("process function:loader wait for != 0" );
}
}
catch(Exception ex)
{
System.out.println("process function:loader execute exception"+ex.toString());
}
你试试!
------解决方案--------------------按说Runtime.getRuntime().exec("cmd /c start sqlldr test/test@KEN ……或者Runtime.getRuntime().exec("cmd /c sqlldr test/test@KEN ……
这样应该可以啊