//要执行的DOS命令 --数据库 用户名 密码 user/password@database
String dos="sqlldr "+user+"/"+psw+"@"+Database+" control="+fileRoute+""+ctlfileName+" log="+fileRoute+""+logfileName;
String[] cmd = new String[]
{ "cmd.exe", "/C", dos }; // 命令
try
{
Process process = Runtime.getRuntime().exec(cmd);
ins = process.getInputStream(); // 获取执行cmd命令后的信息
BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
String line = null;
while ((line = reader.readLine()) != null)
{
String msg = new String(line.getBytes("ISO-8859-1"), "UTF-8");
System.out.println(msg); // 输出
}
int exitValue = process.waitFor();
if(exitValue==0)
{
System.out.println("返回值:" + exitValue+"\n数据导入成功");
}else
{
System.out.println("返回值:" + exitValue+"\n数据导入失败");
}
process.getOutputStream().close(); // 关闭
其中那个process.waitfor()方法每次都返回2,但是数据插入数据库成功。
插入失败时返回1。
请问返回值总是2是什么原因?